diff --git a/include/stdexec/execution.hpp b/include/stdexec/execution.hpp index 7fd71c5c7..ac7609812 100644 --- a/include/stdexec/execution.hpp +++ b/include/stdexec/execution.hpp @@ -3072,12 +3072,6 @@ namespace stdexec { } }; - template - using __set_value_t = completion_signatures...)>; - - template - using __set_error_t = completion_signatures)>; - template using __completions_t = // __try_make_completion_signatures< @@ -3088,8 +3082,8 @@ namespace stdexec { completion_signatures< set_error_t(__minvoke<_Cvref, std::exception_ptr>), set_stopped_t()>, // NOT TO SPEC - __mbind_front_q<__set_value_t, _Cvref>, - __mbind_front_q<__set_error_t, _Cvref>>; + __transform<_Cvref, __mcompose<__q, __qf>>, + __transform<_Cvref, __mcompose<__q, __qf>>>; template using __clref_t = const __decay_t<_Ty>&; @@ -3196,19 +3190,12 @@ namespace stdexec { struct __split_t { }; struct split_t { - template - requires sender_in<_Sender, empty_env> && __decay_copyable> - auto operator()(_Sender&& __sndr) const { - auto __domain = __get_early_domain(__sndr); - return stdexec::transform_sender(__domain, __make_sexpr(__(), (_Sender&&) __sndr)); - } - - template + template requires sender_in<_Sender, _Env> && __decay_copyable> - auto operator()(_Sender&& __sndr, _Env&& __env) const { + auto operator()(_Sender&& __sndr, _Env&& __env = {}) const { auto __domain = __get_late_domain(__sndr, __env); return stdexec::transform_sender( - __domain, __make_sexpr(__(), (_Sender&&) __sndr), (_Env&&) __env); + __domain, __make_sexpr((_Env&&) __env, (_Sender&&) __sndr)); } STDEXEC_ATTRIBUTE((always_inline)) // @@ -3228,13 +3215,16 @@ namespace stdexec { template using __receiver_t = __t<__meval<__receiver, __cvref_id<_CvrefSender>, __id<_Env>>>; - template - requires sender_to<__child_of<_Sender>, __receiver_t<__child_of<_Sender>, _Env>> - static auto transform_sender(_Sender&& __sndr, _Env __env = {}) { + template + requires sender_to< + __child_of<_Sender>, + __receiver_t<__child_of<_Sender>, __decay_t<__data_of<_Sender>>>> + static auto transform_sender(_Sender&& __sndr) { return __sexpr_apply( - (_Sender&&) __sndr, [&](__ignore, __ignore, _Child&& __child) { - auto __state = __make_intrusive<__sh_state<_Child, _Env>>( - (_Child&&) __child, std::move(__env)); + (_Sender&&) __sndr, + [&](__ignore, _Env&& __env, _Child&& __child) { + auto __state = __make_intrusive<__sh_state<_Child, __decay_t<_Env>>>( + (_Child&&) __child, (_Env&&) __env); return __make_sexpr<__split_t>(__data{std::move(__state)}); }); } @@ -3256,12 +3246,14 @@ namespace stdexec { // ensure_started() is called. template struct __data { - explicit __data(__intrusive_ptr<_ShState> __sh_state) noexcept - : __sh_state(std::move(__sh_state)) { + explicit __data(__intrusive_ptr<_ShState> __ptr) noexcept + : __sh_state(std::move(__ptr)) { + // Eagerly launch the async operation. + __sh_state->__start_op(); } - __data(__data&&) = default; - __data& operator=(__data&&) = default; + __data(__data&&) noexcept = default; + __data& operator=(__data&&) noexcept = default; ~__data() { if (__sh_state != nullptr) { @@ -3277,28 +3269,15 @@ namespace stdexec { struct __ensure_started_t { }; struct ensure_started_t { - template - requires sender_in<_Sender, empty_env> && __decay_copyable> - auto operator()(_Sender&& __sndr) const { - if constexpr (sender_expr_for<_Sender, __ensure_started_t>) { - return (_Sender&&) __sndr; - } else { - auto __domain = __get_early_domain(__sndr); - return stdexec::transform_sender( - __domain, __make_sexpr(__(), (_Sender&&) __sndr)); - } - STDEXEC_UNREACHABLE(); - } - - template + template requires sender_in<_Sender, _Env> && __decay_copyable> - auto operator()(_Sender&& __sndr, _Env&& __env) const { + auto operator()(_Sender&& __sndr, _Env&& __env = {}) const { if constexpr (sender_expr_for<_Sender, __ensure_started_t>) { return (_Sender&&) __sndr; } else { auto __domain = __get_late_domain(__sndr, __env); return stdexec::transform_sender( - __domain, __make_sexpr(__(), (_Sender&&) __sndr), (_Env&&) __env); + __domain, __make_sexpr((_Env&&) __env, (_Sender&&) __sndr)); } STDEXEC_UNREACHABLE(); } @@ -3320,15 +3299,16 @@ namespace stdexec { template using __receiver_t = __t<__meval<__receiver, __cvref_id<_CvrefSender>, __id<_Env>>>; - template - requires sender_to<__child_of<_Sender>, __receiver_t<__child_of<_Sender>, _Env>> - static auto transform_sender(_Sender&& __sndr, _Env __env = {}) { + template + requires sender_to< + __child_of<_Sender>, + __receiver_t<__child_of<_Sender>, __decay_t<__data_of<_Sender>>>> + static auto transform_sender(_Sender&& __sndr) { return __sexpr_apply( - (_Sender&&) __sndr, [&](__ignore, __ignore, _Child&& __child) { - auto __state = __make_intrusive<__sh_state<_Child, _Env>>( - (_Child&&) __child, std::move(__env)); - // Eagerly launch the async operation. - __state->__start_op(); + (_Sender&&) __sndr, + [&](__ignore, _Env&& __env, _Child&& __child) { + auto __state = __make_intrusive<__sh_state<_Child, __decay_t<_Env>>>( + (_Child&&) __child, (_Env&&) __env); return __make_sexpr<__ensure_started_t>(__data{std::move(__state)}); }); }