return makeFuture(Unit{});
}
-// XXX why is the dual necessary here? Can't we just use perfect forwarding
-// and capture func by reference always?
template <class F>
-auto makeFutureWith(
- F&& func,
- typename std::enable_if<!std::is_reference<F>::value, bool>::type sdf)
+auto makeFutureWith(F&& func)
-> Future<typename Unit::Lift<decltype(func())>::type> {
using LiftedResult = typename Unit::Lift<decltype(func())>::type;
- return makeFuture<LiftedResult>(makeTryWith([&func]() {
- return (func)();
+ return makeFuture<LiftedResult>(makeTryWith([&func]() mutable {
+ return func();
}));
}
-template <class F>
-auto makeFutureWith(F const& func)
- -> Future<typename Unit::Lift<decltype(func())>::type> {
- F copy = func;
- using LiftedResult = typename Unit::Lift<decltype(func())>::type;
- return makeFuture<LiftedResult>(makeTryWith(std::move(copy)));
-}
-
template <class T>
Future<T> makeFuture(std::exception_ptr const& e) {
return makeFuture(Try<T>(e));
/** Make a completed Future by executing a function. If the function throws
we capture the exception, otherwise we capture the result. */
template <class F>
-auto makeFutureWith(
- F&& func,
- typename std::enable_if<!std::is_reference<F>::value, bool>::type sdf)
- -> Future<typename Unit::Lift<decltype(func())>::type>;
-
-template <class F>
-auto makeFutureWith(F const& func)
+auto makeFutureWith(F&& func)
-> Future<typename Unit::Lift<decltype(func())>::type>;
/// Make a failed Future from an exception_ptr.