D
Damien
Hi all,
I've run into something confusing on MS VC6. Yeah I know it's old but
that's what the client wants, so...
I'm trying to pass a pointer to a member function as a template
argument, and the compiler gives me an invalid template argument on the
member function address if the member function returns a type. A
member function with a void return type is fine. The example below
demonstrates the problem:
class SomeClass
{
int FuncWithReturn(){return 0;}
void VoidFunc(int arg){};
};
template TemplateRetFunc<class T, class RetType, RetType (T::*F)() >
{
};
template TemplateVoidFunc<class T, class Arg, void (T::*F)(Arg) >
{
};
int main()
{
TemplateRetFunc<SomeClass, int, &SomeClass::FuncWithReturn> test1;
//error
TemplateVoidFunc<SomeClass, int, &SomeClass::VoidFunc> test2; //OK
return 0;
}
Anyone know why having the return type gives an error? I'm fine if I
have to use a void return, I just want to know why.
Damien
Damien
I've run into something confusing on MS VC6. Yeah I know it's old but
that's what the client wants, so...
I'm trying to pass a pointer to a member function as a template
argument, and the compiler gives me an invalid template argument on the
member function address if the member function returns a type. A
member function with a void return type is fine. The example below
demonstrates the problem:
class SomeClass
{
int FuncWithReturn(){return 0;}
void VoidFunc(int arg){};
};
template TemplateRetFunc<class T, class RetType, RetType (T::*F)() >
{
};
template TemplateVoidFunc<class T, class Arg, void (T::*F)(Arg) >
{
};
int main()
{
TemplateRetFunc<SomeClass, int, &SomeClass::FuncWithReturn> test1;
//error
TemplateVoidFunc<SomeClass, int, &SomeClass::VoidFunc> test2; //OK
return 0;
}
Anyone know why having the return type gives an error? I'm fine if I
have to use a void return, I just want to know why.
Damien
Damien