std::packaged_task
这个函数是要跟std::future联合使用的。在异步编程中得到未来值
template<typename FunctionType>
void foo(FunctionType f)
{
// return type is the type of the result when invoking functiontype with no params
using return_type = typename std::result_of<FunctionType()>::type;
// package_task 不接受拷贝构造,而是移动构造,这主要是为了保持他的单例性
std::packaged_task<FunctionType> task(std::move(f));
std::future<return_type> result(task.get_future());
//return result; // need to change void to return type
}