我正在尝试以下程序:
#include<type_traits>
using namespace std;
template <class F, class R = typename result_of<F()>::type>
R call(F& f) { return f(); }
int answer() { return 42; }
int main()
{
call(answer);
return 0;
}
“呼叫(回答)”无法编译
VC 说 'R call(F&)' 不能推断出 'R' 的模板参数
GCC 说 |注意:模板参数推导/替换失败:|错误:函数返回函数
我不确定“函数名称”是否可用于模板。我在哪里弄错了,如何让我的电话(接听)工作?