From c1906a3d2a4cf8b2a096dc0b280e494b807d545c Mon Sep 17 00:00:00 2001 From: Avi Kivity Date: Fri, 17 Jul 2015 16:08:28 +0300 Subject: [PATCH] future: add futurize::make_exception_future() Add a way to create an exceptional future of a type that is not directly known. --- core/future.hh | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/core/future.hh b/core/future.hh index 946d7262e7..d035793c42 100644 --- a/core/future.hh +++ b/core/future.hh @@ -509,6 +509,10 @@ struct futurize { /// and return the result, as a future (if it wasn't already). template static inline type apply(Func&& func, FuncArgs&&... args); + + /// Makes an exceptional future of type \ref type. + template + static type make_exception_future(Arg&& arg); }; /// \cond internal @@ -522,6 +526,9 @@ struct futurize { template static inline type apply(Func&& func, FuncArgs&&... args); + + template + static type make_exception_future(Arg&& arg); }; template @@ -534,6 +541,9 @@ struct futurize> { template static inline type apply(Func&& func, FuncArgs&&... args); + + template + static type make_exception_future(Arg&& arg); }; /// \endcond @@ -967,6 +977,29 @@ typename futurize>::type futurize>::apply(Func&& return func(std::forward(args)...); } +template +template +inline +future +futurize::make_exception_future(Arg&& arg) { + return ::make_exception_future(std::forward(arg)); +} + +template +template +inline +future +futurize>::make_exception_future(Arg&& arg) { + return ::make_exception_future(std::forward(arg)); +} + +template +inline +future<> +futurize::make_exception_future(Arg&& arg) { + return ::make_exception_future<>(std::forward(arg)); +} + /// \endcond #endif /* FUTURE_HH_ */