@@ -269,25 +269,33 @@ namespace stdexec {
269269 __in_which_let_msg<_Set>,
270270 " The senders returned by Function do not all share a common domain" _mstr>;
271271
272- template <class _Set >
272+ template <class _Set , class _Sched >
273273 struct __try_common_domain_fn {
274274 struct __error_fn {
275275 template <class ... _Senders>
276276 using __f = __mexception<__no_common_domain_t <_Set>, _WITH_SENDERS_<_Senders...>>;
277277 };
278278
279+ // If a sender is "scheduler affine", then it will complete on the same execution
280+ // context on which it was started (e.g., just(42)). In this case, the domain of the
281+ // scheduler is the domain of the sender.
282+ template <class ... _Senders>
283+ using __common_domain_t = //
284+ __domain::__common_domain_t <
285+ __if_c<__is_scheduler_affine<_Senders>, schedule_result_t <_Sched>, _Senders>...>;
286+
279287 template <class ... _Senders>
280- using __f = __mcall<__mtry_catch_q<__domain:: __common_domain_t , __error_fn>, _Senders...>;
288+ using __f = __mcall<__mtry_catch_q<__common_domain_t , __error_fn>, _Senders...>;
281289 };
282290
283291 // Compute all the domains of all the result senders and make sure they're all the same
284- template <class _Set , class _Child , class _Fun , class _Env , class _Sched >
292+ template <class _Set , class _Child , class _Fun , class _Sched , class ... _Env >
285293 using __result_domain_t = //
286294 __gather_completions<
287295 _Set,
288- __completion_signatures_of_t <_Child, _Env>,
289- __result_sender_fn<_Set, _Fun, _Sched, _Env>,
290- __try_common_domain_fn<_Set>>;
296+ __completion_signatures_of_t <_Child, _Env... >,
297+ __result_sender_fn<_Set, _Fun, _Sched, _Env... >,
298+ __try_common_domain_fn<_Set, _Sched >>;
291299
292300 template <class _LetTag , class _Env >
293301 auto __mk_transform_env_fn (_Env&& __env) noexcept {
@@ -320,7 +328,7 @@ namespace stdexec {
320328 return __completions_t ();
321329 } else {
322330 using _Sched = __completion_sched<_Child, _Set>;
323- using _Domain = __result_domain_t <_Set, _Child, _Fun, _Env, _Sched >;
331+ using _Domain = __result_domain_t <_Set, _Child, _Fun, _Sched, _Env >;
324332
325333 if constexpr (__merror<_Domain>) {
326334 return _Domain ();
@@ -443,8 +451,19 @@ namespace stdexec {
443451 template <class _Set , class _Domain >
444452 struct __let_impl : __sexpr_defaults {
445453 static constexpr auto get_attrs = //
446- []<class _Child >(__ignore, const _Child& __child) noexcept {
454+ []<class _Fun , class _Child >(const _Fun&, const _Child& __child) noexcept {
455+ if constexpr (!same_as<_Domain, dependent_domain>) {
447456 return __env::__join (prop{get_domain, _Domain ()}, stdexec::get_env (__child));
457+ } else {
458+ using _Sched = __completion_sched<_Child, _Set>;
459+ using _Domain2 = __result_domain_t <_Set, _Child, _Fun, _Sched>;
460+
461+ if constexpr (__merror<_Domain2>) {
462+ return __env::__join (prop{get_domain, dependent_domain ()}, stdexec::get_env (__child));
463+ } else {
464+ return __env::__join (prop{get_domain, _Domain2 ()}, stdexec::get_env (__child));
465+ }
466+ }
448467 };
449468
450469 static constexpr auto get_completion_signatures = //
0 commit comments