1
4

1 回答 1

1

I think you need to change the returned function signature to T... instead of just ... otherwise it expects a variable arglist even when it should just be empty.

template<typename RetType, typename... T>
RetType (*findFunction(const std::string& funcName))(T... Ts) const
{
    return (RetType (*)(T...))findFunction(funcName);
}

Then call it without the void in the type list and it should work:

const char* (*whatwhat)() = test.findFunction<const char*>(name);

With these changes it compiles for me on gcc-4.5.1: http://ideone.com/UFbut

于 2012-01-18T01:41:17.683 回答