std::async variant which works over a collection
问题 Using std::async I was wondering whether it is possible to have a helper function, which creates std::future s from a collection (one future for every collection element). Often I have the following situation: auto func = []( decltype(collection)::reference value ) { //Some async work }; typedef std::result_of<decltype(func)>::type ResultType; std::vector<std::future<ResultType>> futures; futures.reserve(collection.size()); // Create all futures for( auto& element : collection ) { futures