3 #include <boost/function.hpp>
4 #include <boost/optional.hpp>
12 auto flatten(std::future<T>&& f) -> std::future<typename std::decay<decltype(f.get().get())>::type>
14 auto shared_f = f.share();
15 return std::async(std::launch::deferred, [=]() mutable -> typename std::decay<decltype(f.get().get())>::type
17 return shared_f.get().get();
22 bool is_ready(const F& future)
24 return future.wait_for(std::chrono::seconds(0)) == std::future_status::ready;
28 * Wrap a value in a future with an already known result.
30 * Useful when the result of an operation is already known at the time of
33 * @param value The r-value to wrap.
35 * @return The future with the result set.
38 std::future<R> make_ready_future(R&& value)
44 return p.get_future();
47 static std::future<void> make_ready_future()
53 return p.get_future();