@@ -4938,8 +4938,8 @@ namespace stdexec {
49384938set_error_t ,
49394939set_stopped_t >>;
49404940
4941- template <class _SchedulerId ,class _CvrefSenderId ,class _ReceiverId >
4942- struct __operation1 ;
4941+ template <class _SchedulerId ,class _Variant ,class _ReceiverId >
4942+ struct __operation1_base ;
49434943
49444944// This receiver is to be completed on the execution context
49454945// associated with the scheduler. When the source sender
@@ -4948,14 +4948,14 @@ namespace stdexec {
49484948// read the completion out of the operation state and forward it
49494949// to the output receiver after transitioning to the scheduler's
49504950// context.
4951- template <class _SchedulerId ,class _CvrefSenderId ,class _ReceiverId >
4951+ template <class _SchedulerId ,class _Variant ,class _ReceiverId >
49524952struct __receiver2 {
49534953using _Receiver = stdexec::__t <_ReceiverId>;
49544954
49554955struct __t {
49564956using is_receiver =void ;
49574957using __id = __receiver2;
4958- stdexec:: __t <__operation1< _SchedulerId,_CvrefSenderId , _ReceiverId> >* __op_state_;
4958+ __operation1_base< _SchedulerId,_Variant , _ReceiverId>* __op_state_;
49594959
49604960// If the work is successfully scheduled on the new execution
49614961// context and is ready to run, forward the completion signal in
@@ -4984,15 +4984,15 @@ namespace stdexec {
49844984// context of the scheduler. That second receiver will read the
49854985// completion information out of the operation state and propagate
49864986// it to the output receiver from within the desired context.
4987- template <class _SchedulerId ,class _CvrefSenderId ,class _ReceiverId >
4987+ template <class _SchedulerId ,class _Variant ,class _ReceiverId >
49884988struct __receiver1 {
49894989using _Scheduler = stdexec::__t <_SchedulerId>;
49904990using _Receiver = stdexec::__t <_ReceiverId>;
4991- using __receiver2_t = stdexec::__t <__receiver2<_SchedulerId,_CvrefSenderId , _ReceiverId>>;
4991+ using __receiver2_t = stdexec::__t <__receiver2<_SchedulerId,_Variant , _ReceiverId>>;
49924992
49934993struct __t {
49944994using is_receiver =void ;
4995- stdexec:: __t <__operation1< _SchedulerId,_CvrefSenderId , _ReceiverId> >* __op_state_;
4995+ __operation1_base< _SchedulerId,_Variant , _ReceiverId>* __op_state_;
49964996
49974997template <class ... _Args>
49984998static constexpr bool __nothrow_complete_ = (__nothrow_decay_copyable<_Args> && ...);
@@ -5027,52 +5027,62 @@ namespace stdexec {
50275027 };
50285028 };
50295029
5030+ template <class _SchedulerId ,class _Variant ,class _ReceiverId >
5031+ struct __operation1_base : __immovable {
5032+ using _Scheduler = stdexec::__t <_SchedulerId>;
5033+ using _Receiver = stdexec::__t <_ReceiverId>;
5034+ using __receiver2_t = stdexec::__t <__receiver2<_SchedulerId, _Variant, _ReceiverId>>;
5035+
5036+ _Scheduler __sched_;
5037+ _Receiver __rcvr_;
5038+ _Variant __data_;
5039+ connect_result_t <schedule_result_t <_Scheduler>,__receiver2_t > __state2_;
5040+
5041+ __operation1_base (_Scheduler __sched, _Receiver&& __rcvr)
5042+ : __sched_((_Scheduler&&) __sched)
5043+ , __rcvr_((_Receiver&&) __rcvr)
5044+ , __state2_(connect(schedule(__sched_),__receiver2_t {this })) {
5045+ }
5046+
5047+ void __complete ()noexcept {
5048+ STDEXEC_ASSERT (!__data_.valueless_by_exception ());
5049+ std::visit (
5050+ [this ]<class _Tup >(_Tup& __tupl) ->void {
5051+ if constexpr (same_as<_Tup, std::monostate>) {
5052+ std::terminate ();// reaching this indicates a bug in schedule_from
5053+ }else {
5054+ std::apply (
5055+ [&]<class ... _Args>(auto __tag, _Args&... __args) ->void {
5056+ __tag ((_Receiver&&) __rcvr_, (_Args&&) __args...);
5057+ },
5058+ __tupl);
5059+ }
5060+ },
5061+ __data_);
5062+ }
5063+ };
5064+
50305065template <class _SchedulerId ,class _CvrefSenderId ,class _ReceiverId >
50315066struct __operation1 {
50325067using _Scheduler = stdexec::__t <_SchedulerId>;
50335068using _CvrefSender = stdexec::__cvref_t <_CvrefSenderId>;
50345069using _Receiver = stdexec::__t <_ReceiverId>;
5035- using __receiver1_t = stdexec::__t <__receiver1<_SchedulerId, _CvrefSenderId, _ReceiverId>>;
5036- using __receiver2_t = stdexec::__t <__receiver2<_SchedulerId, _CvrefSenderId, _ReceiverId>>;
50375070using __variant_t =__variant_for_t <_CvrefSender,env_of_t <_Receiver>>;
5071+ using __receiver1_t = stdexec::__t <__receiver1<_SchedulerId,__variant_t , _ReceiverId>>;
5072+ using __base_t = __operation1_base<_SchedulerId,__variant_t , _ReceiverId>;
50385073
5039- struct __t {
5074+ struct __t : __base_t {
50405075using __id = __operation1;
5041- _Scheduler __sched_;
5042- _Receiver __rcvr_;
5043- __variant_t __data_;
50445076connect_result_t <_CvrefSender,__receiver1_t > __state1_;
5045- connect_result_t <schedule_result_t <_Scheduler>,__receiver2_t > __state2_;
50465077
50475078__t (_Scheduler __sched, _CvrefSender&& __sndr, _Receiver&& __rcvr)
5048- : __sched_((_Scheduler&&) __sched)
5049- , __rcvr_((_Receiver&&) __rcvr)
5050- , __state1_(connect((_CvrefSender&&) __sndr,__receiver1_t {this }))
5051- , __state2_(connect(schedule(__sched_),__receiver2_t {this })) {
5079+ :__base_t {(_Scheduler&&) __sched, (_Receiver&&) __rcvr}
5080+ , __state1_(connect((_CvrefSender&&) __sndr,__receiver1_t {this })) {
50525081 }
50535082
5054- STDEXEC_IMMOVABLE (__t );
5055-
50565083friend void tag_invoke (start_t ,__t & __op_state)noexcept {
50575084start (__op_state.__state1_ );
50585085 }
5059-
5060- void __complete ()noexcept {
5061- STDEXEC_ASSERT (!__data_.valueless_by_exception ());
5062- std::visit (
5063- [&]<class _Tup >(_Tup& __tupl) ->void {
5064- if constexpr (same_as<_Tup, std::monostate>) {
5065- std::terminate ();// reaching this indicates a bug in schedule_from
5066- }else {
5067- std::apply (
5068- [&]<class ... _Args>(auto __tag, _Args&... __args) ->void {
5069- __tag ((_Receiver&&) __rcvr_, (_Args&&) __args...);
5070- },
5071- __tupl);
5072- }
5073- },
5074- __data_);
5075- }
50765086 };
50775087 };
50785088