开发者

Having problem passing member function pointers to templatized member function on gcc

开发者 https://www.devze.com 2023-03-06 00:50 出处:网络
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?

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

0

精彩评论

暂无评论...
验证码 换一张
取 消