get_env() specified in terms of as_const() but this doesn't work with rvalue sendersSection: 33.5.2 [exec.get.allocator], 33.5.3 [exec.get.stop.token], 33.5.4 [exec.get.env], 33.5.5 [exec.get.domain], 33.5.6 [exec.get.scheduler], 33.5.7 [exec.get.delegation.scheduler], 33.5.8 [exec.get.fwd.progress], 33.5.9 [exec.get.compl.sched] Status: WP Submitter: Lewis Baker Opened: 2024-11-10 Last modified: 2025-02-16
Priority: Not Prioritized
View all issues with WP status.
Discussion:
The current specification of std::execution::get_env() defines get_env(o) as as_const(o).get_env().
However, the as_const() function has a deleted rvalue-taking overload, meaning that you cannot pass temporaries to it.
get_env() which pass expressions which are either potentially rvalues
(e.g. in definition of connect(sndr, rcvr) it uses the expression get_env(rcvr), but rcvr could be,
and usually is, a prvalue) or always rvalues (e.g. scheduler concept has the expression
get_env(schedule(std::forward<Sch>(sch)))).
The intent here was that get_env() is a function that takes as an argument a const T& and thus
allows prvalues to bind to it. We basically just want to require that get_env() finds a const-qualified
member-function. The use of as_const() does not seem to mirror the semantics of a function with a
const T& parameter, so I suggest we change it to something else that expresses the intent.
[2025-02-07; Reflector poll]
Set status to Tentatively Ready after five votes in favour during reflector poll.
This could use the "reified object" idea from 25.3 [range.access].
[Hagenberg 2025-02-16; Status changed: Voting → WP.]
Proposed resolution:
This wording is relative to N4993.
Add to the end of 33.1 [exec.general] as indicated:
-?- For a subexpression
expr, letAS-CONST(expr)be expression-equivalent to[](const auto& x) noexcept -> const auto& { return x; }(expr)
Modify 33.5.2 [exec.get.allocator] as indicated:
-1-
-2- The nameget_allocatorasks a queryable object for its associated allocator.get_allocatordenotes a query object. For a subexpressionenv,get_allocator(env)is expression-equivalent toMANDATE-NOTHROW(.as_constAS-CONST(env).query(get_allocator))
Modify 33.5.3 [exec.get.stop.token] as indicated:
-2- The name
get_stop_tokendenotes a query object. For a subexpressionenv,get_stop_token(env)is expression-equivalent to:
(2.1) —
MANDATE-NOTHROW(if that expression is well-formed.as_constAS-CONST(env).query(get_stop_token))
Modify 33.5.4 [exec.get.env] as indicated:
-1-
execution::get_envis a customization point object. For a subexpressiono,execution::get_env(o)is expression-equivalent to:
(1.1) —
MANDATE-NOTHROW(if that expression is well-formed.as_constAS-CONST(o).get_env())
Modify 33.5.5 [exec.get.domain] as indicated:
-2- The name
get_domaindenotes a query object. For a subexpressionenv,get_domain(env)is expression-equivalent toMANDATE-NOTHROW(.as_constAS-CONST(env).query(get_domain))
Modify 33.5.6 [exec.get.scheduler] as indicated:
-2- The name
get_schedulerdenotes a query object. For a subexpressionenv,get_scheduler(env)is expression-equivalent toMANDATE-NOTHROW(.as_constAS-CONST(env).query(get_scheduler))
Modify 33.5.7 [exec.get.delegation.scheduler] as indicated:
-2- The name
get_delegation_schedulerdenotes a query object. For a subexpressionenv,get_delegation_scheduler(env)is expression-equivalent toMANDATE-NOTHROW(.as_constAS-CONST(env).query(get_delegation_scheduler))
Modify 33.5.8 [exec.get.fwd.progress] as indicated:
-2- The name
get_forward_progress_guaranteedenotes a query object. For a subexpressionsch, letSchbedecltype((sch)). IfSchdoes not satisfyscheduler,get_forward_progress_guaranteeis ill-formed. Otherwise,get_forward_progress_guarantee(sch)is expression-equivalent to:
(2.1) —
MANDATE-NOTHROW(if that expression is well-formed.as_constAS-CONST(sch).query(get_forward_progress_guarantee))
Modify 33.5.9 [exec.get.compl.sched] as indicated:
-2- The name
get_completion_schedulerdenotes a query object template. For a subexpressionq, the expressionget_completion_scheduler<completion-tag>(q)is ill-formed ifcompletion-tagis not one ofset_value_t,set_error_t, orset_stopped_t. Otherwise,get_completion_scheduler<completion-tag>(q)is expression-equivalent toMANDATE-NOTHROW(as_constAS-CONST(q).query(get_completion_scheduler<completion-tag>))