"unqualified-id" compiler error when accessing member of a class through a pointer

218 views Asked by At

I am currently working on a delegate class for use in several of my programs. My code for loose functions works, but I am getting a compiler error in the code that binds member functions. The compiler error contents are

error: expected unqualified-id before '(' token.

I'm not seeing any reason why this would be the case. My code, excluding parts that compile nicely, is as follows:

template <typename T> class Delegate;

template <typename R, typename... Args>
class Delegate<R(Args)>
{
    typedef void* InstancePtr;   

//...

    template <typename C, R (C::*classFunction)(Args...)>
    static inline R MakeStubFunction(InstancePtr instance, Args... args)
    {
        //  vvv  error on this line  vvv
        return ( static_cast<C*>(instance)->(*classFunction) )(args...);
    }

//...

 };

Can anyone point out the source of the compiler error? In the interest of being able to solve such problems in the future, what is meant by "unqualified-id"?

1

There are 1 answers

4
Columbo On BEST ANSWER

Remove the braces and use the ->* operator:

return ( static_cast<C*>(instance)->*classFunction )(args...);