pointer to SPECIALIZED member function template not legal c++ ?

I

Ingo

Hi,

the following code:


template< typename objectT
, typename worldT >
void(objectT::* getInvocationFunctionFor( objectT* v ))(worldT&)
{
return &(objectT::custom_func/*<worldT>*/);
}

will work unless I activate the commented template arg.

Only exception is VC++, but GCC 4.x and Comeau won't take it.

I would like to know, whether there is a good reason for making this
illegal and whether somebody knows a nice workaround. Or did I do
something stupid here?

Ingo
 
A

acehreli

template< typename objectT
                                , typename worldT >
void(objectT::* getInvocationFunctionFor( objectT* v ))(worldT&)
{
        return &(objectT::custom_func/*<worldT>*/);

}

I recommend using typedef's to make the code readable. I can only fool
myself to think what the return type possibly is. Still, your problem
may be that you are missing a 'template' keyword as in:

return &(objectT::template custom_func<worldT>);

Without that, the compiler would take '<' as the "less than" operator.

Ali
 
I

Ingo

I recommend using typedef's to make the code readable. I can only fool
myself to think what the return type possibly is. Still, your problem

Could you tell me how to do that??

The return type is a pointer to a member function. The argument of
that member function depends on functions actual template arguments.
Since there is no templated typedef, how would you use a typedef in
this situation?
may be that you are missing a 'template' keyword as in:

   return &(objectT::template custom_func<worldT>);

Without that, the compiler would take '<' as the "less than" operator.

Thank you,
this did it. Should have been obvious to me. I just spend too much
time coding with vc.

Ingo
 

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
474,432
Messages
2,571,682
Members
48,796
Latest member
Greg L.

Latest Threads

Top