我正在为 std::async 编写自己的实现并遇到一些困难。我有这样的签名:
template<class Fn>
Future<typename std::result_of<Fn>::type> runAsync(const Fn & task);
但是使用这个,我得到了“error C2893: Failed to specialize function template”。找出仿函数的返回类型并正确初始化 Future 的好方法是什么?
最佳答案
你错过了 ()
秒。你可以做...
result_of<Fn()>
或
result_of<Fn(void)>
关于c++ - 找出仿函数 C++11\Boost 的返回类型,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22101813/