Taking address of member template function.

S

Stuart Redmann

Hello newsgroup,

I try to take the address of a member template function, but I can't
succeed. My copy of Bjarne Stroupstrup says nothing against this, so I
guess that what I want to achive is not beyond the possibilities of C++,
but beyond the abilities of my compiler (Visual C++ 6.0). Following code
won't compile (error C2039: 'SomeFunc' : Is no element of '`global
namespace''). Any suggestions would be highly appreciated.

class TestClass
{
public:
template<int t_ID>
void SomeFunc ()
{}
};

void (TestClass::*pFuncPtr) () = TestClass<0>::SomeFunc;

Thanks in advance,
Stuart
 
T

Thomas Tutone

I try to take the address of a member template function, but I can't
succeed. My copy of Bjarne Stroupstrup says nothing against this, so I
guess that what I want to achive is not beyond the possibilities of C++,
but beyond the abilities of my compiler (Visual C++ 6.0). Following code
won't compile (error C2039: 'SomeFunc' : Is no element of '`global
namespace''). Any suggestions would be highly appreciated.

class TestClass
{
public:
template<int t_ID>
void SomeFunc ()
{}

};

void (TestClass::*pFuncPtr) () = TestClass<0>::SomeFunc;

Two suggestions:

1. Your syntax is wrong. Change the last line to:

void (TestClass::*pFuncPtr) () = &TestClass::SomeFunc<0>;

2. Get a new compiler - Visual C++ 6.0 is horribly out of date.

Best regards,

Tom
 
S

Stuart Redmann

Thomas said:
Two suggestions:

1. Your syntax is wrong. Change the last line to:

void (TestClass::*pFuncPtr) () = &TestClass::SomeFunc<0>;

That is what I was afraid of: With this syntax I get
fatal error C1001: INTERNAL COMPILER- ERROR
2. Get a new compiler - Visual C++ 6.0 is horribly out of date.

I will. Honestly.

Thanks,
Stuart
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top