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

Discussion in 'C++' started by Ingo, Oct 19, 2008.

  1. Ingo

    Ingo Guest

    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
     
    Ingo, Oct 19, 2008
    #1
    1. Advertising

  2. Ingo

    Guest

    On Oct 19, 2:29 pm, Ingo <> wrote:

    > 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
     
    , Oct 19, 2008
    #2
    1. Advertising

  3. Ingo

    Ingo Guest


    >
    > 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

    > Ali
     
    Ingo, Oct 20, 2008
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Robert Allan Schwartz
    Replies:
    1
    Views:
    399
    Victor Bazarov
    Aug 9, 2004
  2. Fraser Ross
    Replies:
    4
    Views:
    1,052
    Fraser Ross
    Aug 14, 2004
  3. BigMan
    Replies:
    3
    Views:
    1,436
    BigMan
    Apr 22, 2005
  4. Replies:
    1
    Views:
    474
    Victor Bazarov
    Jul 20, 2005
  5. Igor R.
    Replies:
    2
    Views:
    222
    Igor R.
    Jun 1, 2011
Loading...

Share This Page