diff --git a/include/stdexec/__detail/__execution_fwd.hpp b/include/stdexec/__detail/__execution_fwd.hpp index d95559fa6..27dd5c1aa 100644 --- a/include/stdexec/__detail/__execution_fwd.hpp +++ b/include/stdexec/__detail/__execution_fwd.hpp @@ -165,6 +165,15 @@ namespace stdexec { } using __transfer::transfer_t; + extern const transfer_t transfer; + + ////////////////////////////////////////////////////////////////////////////////////////////////// + namespace __transfer_just { + struct transfer_just_t; + } + + using __transfer_just::transfer_just_t; + extern const transfer_just_t transfer_just; ////////////////////////////////////////////////////////////////////////////////////////////////// namespace __on_v2 { diff --git a/include/stdexec/execution.hpp b/include/stdexec/execution.hpp index 121399ca5..291a0c9ef 100644 --- a/include/stdexec/execution.hpp +++ b/include/stdexec/execution.hpp @@ -5537,23 +5537,48 @@ namespace stdexec { ///////////////////////////////////////////////////////////////////////////// // [execution.senders.transfer_just] namespace __transfer_just { + inline auto __transfer_just_tag_invoke() { + return [](_Ts&&... __ts) -> tag_invoke_result_t { + return tag_invoke(transfer_just, (_Ts&&) __ts...); + }; + } + struct transfer_just_t { + using _Data = __0; + using __legacy_customizations_t = // + __types<__apply_t(decltype(__transfer_just_tag_invoke()), _Data)>; + template - requires tag_invocable - && sender> - auto operator()(_Scheduler&& __sched, _Values&&... __vals) const - noexcept(nothrow_tag_invocable) - -> tag_invoke_result_t { - return tag_invoke(*this, (_Scheduler&&) __sched, (_Values&&) __vals...); + auto operator()(_Scheduler&& __sched, _Values&&... __vals) const { + auto __domain = query_or(get_domain, __sched, default_domain()); + return stdexec::transform_sender( + __domain, + make_sender_expr( + std::tuple{(_Scheduler&&) __sched, (_Values&&) __vals...})); } - template - requires( - !tag_invocable - || !sender>) - auto operator()(_Scheduler&& __sched, _Values&&... __vals) const - -> decltype(transfer(just((_Values&&) __vals...), (_Scheduler&&) __sched)) { - return transfer(just((_Values&&) __vals...), (_Scheduler&&) __sched); + template _Sender> + static auto get_env(const _Sender& __sndr) noexcept { + return __apply( + [&](const _Scheduler& __sched, auto&&...) noexcept { + return __t<__schedule_from::__environ<__id<_Scheduler>>>{__sched}; + }, + apply_sender((_Sender&&) __sndr, __detail::__get_data())); + } + + template + static auto transform_sender(_Sender&& __sndr, const _Env& __env) { + return __apply( + [&](_Scheduler&& __sched, _Values&&... __vals) { + auto __domain = __get_env_domain(__env); + return stdexec::transform_sender( + __domain, + transfer( + stdexec::transform_sender(__domain, just((_Values&&) __vals...), __env), + (_Scheduler&&) __sched), + __env); + }, + apply_sender((_Sender&&) __sndr, __detail::__get_data())); } }; } // namespace __transfer_just