找出一个仿函数C ++ 11 \ Boost的返回类型

时间:2014-02-28 17:24:11

标签: c++ boost c++11 asynchronous

我正在为std :: async编写自己的实现并遇到一些困难。我有这样的签名:

template<class Fn>
Future<typename std::result_of<Fn>::type> runAsync(const Fn & task);

但是使用这个,我得到了“错误C2893:无法专门化功能模板”。找出函数返回类型并正确初始化Future的好方法是什么?

1 个答案:

答案 0 :(得分:4)

你错过了()。你可以做任何一个......

result_of<Fn()>

result_of<Fn(void)>