mirror of
https://github.com/Naios/continuable.git
synced 2025-12-06 08:46:44 +08:00
Add a supplier overload to make_ready_continuable
This commit is contained in:
parent
d30814c2ff
commit
db40ba883f
@ -830,7 +830,8 @@ constexpr auto make_ready_continuable() {
|
||||
/// the promise with the given value.
|
||||
///
|
||||
/// \copydetails make_ready_continuable()
|
||||
template <typename Result>
|
||||
template <typename Result, std::enable_if_t<!detail::traits::is_invocable<
|
||||
std::decay<Result>>::value>* = nullptr>
|
||||
constexpr auto make_ready_continuable(Result&& result) {
|
||||
return make_continuable<std::decay_t<Result>>( // ...
|
||||
[result = std::forward<Result>(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>(callable))
|
||||
/// ```
|
||||
///
|
||||
/// \since 3.1.0
|
||||
template <typename Callable, std::enable_if_t<detail::traits::is_invocable<
|
||||
std::decay<Callable>>::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>(callable));
|
||||
}
|
||||
|
||||
/// Returns a continuable_base with multiple result values which instantly
|
||||
/// resolves the promise with the given values.
|
||||
///
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user