I'm having problem passing member function pointers to templatized member function on gcc. Does 开发者_开发知识库anyone know how to modify the code below to get gcc to accept what I am trying to do?
class Foo
{
public:
template <class C, class R>
void Execute(R(typename C::*memFn)())
{
}
};
I get the following errors when trying to compile the code:
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
The version of gcc that I am using is 4.4.2.
Thank you very much for your help!
You don't need typename
. Remove that and it should work. (I tested it on gcc 4.3.2).
精彩评论