0
我试图编译简单templetized包装在Visual Studio 2015完美转发函数指针调用
template<typename Rv, typename ...Args>
Rv call(Rv(*fp)(Args...), Args&&...args) {
return (*fp)(std::forward<Args>(args)...);
}
int iArg;
void(*fn)(int);
call(fn, iArg);`
我得到以下编译器错误:
test.cpp(30): error C2672: 'call': no matching overloaded function found
error C2782: 'Rv call(Rv (__cdecl *)(Args...),Args &&...)': template parameter 'Args' is ambiguous
1> test.cpp(22): note: see declaration of 'call'
1> test.cpp(30): note: could be 'int'
1> test.cpp(30): note: or 'int&'
为什么?
在此先感谢
工作。感谢您的快速回复 –
@ U.Mann不要忘记将答案标记为解决方案! – ProXicT