我在将成员函数指针传递给 gcc 上的模板化成员函数时遇到问题。有谁知道如何修改下面的代码以让 gcc 接受我正在尝试做的事情?
class Foo
{
public:
template <class C, class R>
void Execute(R(typename C::*memFn)())
{
}
};
尝试编译代码时出现以下错误:
test.cpp:40: error: 'memFn' was not declared in this scope
test.cpp:40: error: expected primary-expression before '(' token
test.cpp:40: error: expected identifier before '*' token
test.cpp:40: error: expected '(' before '*' token
test.cpp:40: error: 'memFn' was not declared in this scope
test.cpp:40: error: variable or field 'Execute' declared void
我使用的 gcc 版本是 4.4.2。
非常感谢您的帮助!