From d8c5807af6bb2ad1ba1973cc94e2191a472a53cb Mon Sep 17 00:00:00 2001 From: tqcq <99722391+tqcq@users.noreply.github.com> Date: Tue, 26 Mar 2024 08:51:17 +0800 Subject: [PATCH] feat update --- include/sled/futures/detail/just.h | 6 +++--- include/sled/futures/detail/then.h | 10 +++++----- include/sled/futures/detail/traits.h | 3 +++ 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/include/sled/futures/detail/just.h b/include/sled/futures/detail/just.h index cba8b15..38a78f8 100644 --- a/include/sled/futures/detail/just.h +++ b/include/sled/futures/detail/just.h @@ -25,15 +25,15 @@ struct JustSender { template JustOperation Connect(R receiver) { - return {value, receiver}; + return {std::forward(value), receiver}; } }; template JustSender -Just(T value) +Just(T &&value) { - return {value}; + return {std::forward(value)}; } }// namespace detail diff --git a/include/sled/futures/detail/then.h b/include/sled/futures/detail/then.h index 075d152..2b497e8 100644 --- a/include/sled/futures/detail/then.h +++ b/include/sled/futures/detail/then.h @@ -13,12 +13,12 @@ struct ThenReceiver { F func; bool stopped = false; - template + template> void SetValue(U &&val) { if (stopped) { return; } try { - receiver.SetValue(func(std::forward(val))); + receiver.SetValue(std::forward(func(std::forward(val)))); } catch (...) { SetError(std::current_exception()); } @@ -49,7 +49,7 @@ struct ThenOperation { template struct ThenSender { - using result_t = invoke_result_t; + using result_t = invoke_result_t::result_t>; S sender; F func; @@ -62,9 +62,9 @@ struct ThenSender { template ThenSender -Then(S sender, F &&func) +Then(S &&sender, F &&func) { - return {sender, std::forward(func)}; + return {std::forward(sender), std::forward(func)}; } }// namespace detail diff --git a/include/sled/futures/detail/traits.h b/include/sled/futures/detail/traits.h index fe709a9..63b9b14 100644 --- a/include/sled/futures/detail/traits.h +++ b/include/sled/futures/detail/traits.h @@ -18,6 +18,9 @@ using ConnectResultT = typename ConnectResult::type; template using invoke_result_t = eggs::invoke_result_t; +template +using decay_t = typename std::decay::type; + }// namespace detail }// namespace sled #endif// SLED_FUTURES_DETAIL_TRAITS_H