From db40ba883fd1f462711d5e3e29bc65332c33fd8d Mon Sep 17 00:00:00 2001 From: Denis Blank Date: Tue, 13 Mar 2018 13:13:39 +0100 Subject: [PATCH] Add a supplier overload to make_ready_continuable --- include/continuable/continuable-base.hpp | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/include/continuable/continuable-base.hpp b/include/continuable/continuable-base.hpp index e33e12a..9629361 100644 --- a/include/continuable/continuable-base.hpp +++ b/include/continuable/continuable-base.hpp @@ -830,7 +830,8 @@ constexpr auto make_ready_continuable() { /// the promise with the given value. /// /// \copydetails make_ready_continuable() -template +template >::value>* = nullptr> constexpr auto make_ready_continuable(Result&& result) { return make_continuable>( // ... [result = std::forward(result)](auto&& promise) mutable { @@ -838,6 +839,22 @@ constexpr auto make_ready_continuable(Result&& result) { }); } +/// Returns a continuable_base with which arguments are dependent on the +/// given supplier callable object. +/// +/// The signature of the resulting continuable_base is equal to the expression: +/// ````cpp +/// make_ready_continuable().then(std::forward(callable)) +/// ``` +/// +/// \since 3.1.0 +template >::value>* = nullptr> +constexpr auto make_ready_continuable(Callable&& callable) { + // TODO Improve this for elliding the temporary object + return make_ready_continuable().then(std::forward(callable)); +} + /// Returns a continuable_base with multiple result values which instantly /// resolves the promise with the given values. ///