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