Con*_*uit 1 c++ void-pointers c++11
我目前正在编写一个委托类,用于我的几个程序.我的松散函数代码有效,但我在绑定成员函数的代码中遇到编译器错误.编译器错误内容是
错误:在'('标记之前的预期unqualified-id.
我没有看到为什么会出现这种情况.我的代码,不包括编译得很好的部分,如下所示:
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...);
}
//...
};
Run Code Online (Sandbox Code Playgroud)
任何人都可以指出编译器错误的来源吗?为了能够在将来解决这些问题,"不合格身份"是什么意思?
删除大括号并使用->*运算符:
return ( static_cast<C*>(instance)->*classFunction )(args...);
Run Code Online (Sandbox Code Playgroud)