| Document #: | P3826R3 [Latest] [Status] |
| Date: | 2026-01-05 |
| Project: | Programming Language C++ |
| Audience: |
SG1 Concurrency and Parallelism Working Group LEWG Library Evolution Working Group LWG Library Working Group |
| Reply-to: |
Eric Niebler <eric.niebler@gmail.com> |
transform_senderIn the current Working Draft, 33 [exec] has sender algorithms that are customizable. While the sender/receiver concepts and the algorithms themselves have been stable for several years now, the customization mechanism has seen a fair bit of recent churn. [P3718R0] is the latest effort to shore up the mechanism. Unfortunately, there are gaps in its proposed resolution. This paper details those gaps.
The problem and its solution are easy to describe, but the changes are not trivial. The fix has been implemented twice, largely independently and causing no bug reports. This paper proposes to fix the issue for C++26.
get_completion_domain<>(attrs, env...)
query that defaults to get_completion_domain<set_value_t>(attrs, env...).indeterminate_domain<>.[P3718R0] identifies real problems with the status quo of sender algorithm customization. It proposes using information from the sender about where it will complete during “early” customization, which happens when a sender algorithm constructs and returns a sender; and it proposes using information from the receiver about where the operation will start during “late” customization, when the sender and the receiver are connected.
The problem with this separation of responsibilities is:
A simple example is the
just()
sender; it completes inline wherever it is started. The information
about where a sender will start is not known during early customization,
when the sender is being asked for this information.
And even if we knew where the sender will start, there is no generic interface for asking a sender where it will complete given where it will start. There currently is no such API, which is the whole problem in a nutshell.
This section illustrates the above problem by walking through the algorithm selection process proposed by P3718. Consider the following example:
namespace ex = std::execution; auto sndr = ex::starts_on(gpu, ex::just()) | ex::then(fn); std::this_thread::sync_wait(std::move(sndr));
… where gpu is a scheduler that
runs work (unsurprisingly) on a GPU.
fn will execute on the GPU, so a
GPU implementation of then should be
used. By the proposed resolution of P3718, algorithm customization
proceeds as follows:
During early customization, when starts_on(gpu, just()) | then(fn)
is executing, the then CPO asks the
starts_on(gpu, just())
sender where it will complete as if by:
auto& [_, fn, child1] = *this; // *this is a then sender // child1 is a starts_on sender auto dom1 = ex::get_domain(ex::get_env(child1));
The starts_on sender will in
turn ask the
just()
sender, as if by:
auto& [_, sch, child2] = *this; // *this is a starts_on sender // child2 is a just sender auto dom2 = ex::get_domain(ex::get_env(child2));
As discussed, the
just()
sender doesn’t know where it will complete until it knows where it will
be started, but that information is not yet available. As a result,
dom2 ends up as
default_domain, which is then
reported as the domain for the
starts_on sender. That’s incorrect.
The starts_on sender will complete
on the GPU.
The then CPO uses
default_domain to find an
implementation of the then
algorithm, which will find the default implementation. As a result, the
then CPO returns an ordinary
then sender.
When that then sender is
connected to sync_wait’s receiver,
late customization happens.
connect asks
sync_wait’s receiver where the
then sender will be started. It does
that with the query get_domain(get_env(rcvr)).
sync_wait starts operations on the
current thread, so the get_domain
query will return default_domain. As
with early customization, late customization will also not find a GPU
implementation.
The end result of all of this is that a default (which is effectively
a CPU) implementation will be used to evaluate the
then algorithm on the GPU. That is a
bad state of affairs.
Here is a list of possible ways to address this problem for C++26, sorted by descending awfulness.
std::execution
additionsAlthough the safest option, I hope most agree that such a drastic
step is not warranted by this issue. Pulling the
sender abstraction and everything
that depends on it would result in the removal of:
The sender/receiver-related concepts and customization points, without which the ecosystem will have no shared async abstraction, and which will set back the adoption of structured concurrency three years.
The sender algorithms, which capture common async patterns and make them reusable,
execution::counting_scope
and execution::simple_counting_scope,
and related features for incremental adoption of structured
concurrency,
execution::parallel_scheduler
and all of its related APIs, and
execution::task
and execution::task_scheduler
(C++26 will still not have a standard coroutine task type
<heavy sigh>).
This option should only be considered if all the other options are determined to have unacceptable risk.
This option would keep all of the above library components with the exception of the customizable sender algorithms:
then,
upon_error,
upon_stoppedlet_value,
let_error,
let_stoppedbulk,
bulk_chunked,
bulk_unchunkedstarts_on,
continues_on,
onwhen_all,
when_all_with_variantstopped_as_optional,
stopped_as_errorinto_variantsync_waitaffine_onThis would leave users with no easy standard way to start work on a given execution context, or transition to another execution context, or to execute work in parallel, or to wait for work to finish.
In fact, without the bulk
algorithms, we leave no way for the
parallel_scheduler to execute work
in parallel!
While still delivering a standard async abstraction with minimal risk, the loss of the algorithms would make it just an abstraction. Like coroutines, adoption of senders as an async lingua franca will be hampered by lack of standard library support.
In this option, we ship everything currently in the Working Draft but remove the ability to customize the algorithms. This gives us a free hand to design a better customization mechanism for C++29 – provided we have confidence that those new customization hooks can be added without break existing behavior.
This option is not as low-risk as it may seem. Firstly, it is difficult to be confident that algorithm customization can be added back without breaking code. Improved customization hooks have been implemented, and wording for the removal has been written such that that the new hooks can be standardized without breaking changes, to the best of the author’s ability.
Secondly, algorithm customizability is a load-bearing feature. Taking
it out is not hard but it isn’t trivial either. Customizability is used
by the parallel_scheduler to
accelerate the bulk family of
algorithms. Although the
task_scheduler does not currently
customize bulk, it should. Some
design work is necessary before algorithm customization can be
removed.
This option is not as reckless as it sounds. We have a fix and the
fix has been implemented in a working and publicly available
execution library (CCCL). It would not be the
first time the Committee shipped a standard with known defects, and the
DR process exists for just this purpose.
One potential problem is that, as DRs go, this one would be large-ish. I do not know if this presents a problem procedurally. If it does, then fixing the problem now would make more sense. Any future DRs are likely to be smaller.
This is the option this paper proposes. The fix is easy to describe:
That is done by passing the receiver’s environment when asking the
sender for its completion domain. Instead of get_domain(get_env(sndr)),
the query would be get_domain(get_env(sndr), get_env(rcvr))
(but with a query other than
get_domain, read on).
That change has some ripple effects, the biggest of which is that the receiver is not known during early customization. Therefore, early customization is irreparably broken and must be removed.
There are no algorithms in std::execution
that are affected by the removal of early customization since they all
do their work lazily. Should a future algorithm be added that eagerly
connects a sender, that algorithm should accept an optional execution
environment by which users can provide the starting domain. That is not
onerous.
There are other ripples from the proposed change. They are described in full detail in section Fixing algorithm customization.
There are risks with trying to fix the problem now. It is a design
change happening uncomfortably close to the release of C++26. One
mitigating factor is that the major Standard Library vendors seem to be
in no rush to implement std::execution. If
there are lingering problems, they could be fixed with the usual DR
process.
This fix has been implemented in NVIDIA’s CCCL library since mid-September 2025 (see NVIDIA/cccl#5793) and in stdexec since late November (see NVIDIA/stdexec#1683). At the time of writing (early January, 2026), the changes have not resulted in any bug reports.
Selecting the right implementation of an algorithm requires requires two things:
Identifying the starting and completing domain of the algorithm’s async operation, and
Using that information to select the preferred implementation for the algorithm that operation represents.
Let’s take these two separately.
As described in Fix
algorithm customization now, so-called “early” customization, which
determines the return type of then(sndr, fn)
for example, is irreparably broken. It needs the sender to know where it
will complete, which it can’t in general.
So the first step is to remove early customization. There is no plan to add it back later.
That leaves “late” customization, which is performed by the
connect
customization point. The receiver, which is an extension of caller,
knows where the operation will start. If the sender is given this
information – that is, if the sender is told where it will start – it
can accurately report where it will complete. This is the key
insight.
When
connect
queries a sender’s attributes for its completion domain, it should pass
the receiver’s environment. That way a sender has all available
information when computing its completion domain.
get_completion_domainIt is sometimes the case that a sender’s value and error completions can happen on different domains. For example, imagine trying to schedule work on a GPU. If it succeeds, you are in the GPU domain, Bob’s your uncle. If scheduling fails, however, the error cannot be reported on the GPU because we failed to make it there!
So asking a sender for a singular completion domain is not flexible enough.
When asking for a completion scheduler, we have three
queries, one for each completion disposition: get_completion_scheduler<set_[value|error|stopped]_t>.
Similarly, we should have three separate queries for a sender’s
completion domain: get_completion_domain<set_[value|error|stopped]_t>.
ASIDE If we have the
get_completion_scheduler queries,
why do we need
get_completion_domain? We can ask
the completion scheduler for its domain, right? The answer is that there
are times when a sender’s completion domain is knowable but the
completion scheduler is not. E.g., when_all(s1, s2)
completes on the completion scheduler of either
s1 or
s2, so its completion scheduler is
indeterminate. But if s1 and
s2 have the same completion
domain, then we know that
when_all will complete in that
domain.
The addition of the completion domain queries creates a nice symmetry as shown in the table below (with additions in green):
Receiver
|
Sender
|
|
|---|---|---|
| Query for scheduler | get_scheduler |
get_completion_scheduler<set_value_t>get_completion_scheduler<set_error_t>get_completion_scheduler<set_stopped_t> |
| Query for domain | get_domain |
get_completion_domain<set_value_t>get_completion_domain<set_error_t>get_completion_domain<set_stopped_t> |
For a sender sndr and an
environment env, we can get the
sender’s set_value completion domain
as follows:
auto completion_domain = get_completion_domain<set_value_t>(get_env(sndr), env);
A sender like
just() would
implement this query as follows:
struct just_attrs { auto query(get_completion_domain_t<set_value_t>, const auto& env) const noexcept { // an inline sender completes where it starts. the domain of the environment is where // the sender will start, so return that. return get_domain(env); } //... }; template<class... Values> struct just_sender { //... auto get_env() const noexcept { return just_attrs{}; } //... };
Note A query that accepts an additional argument is
novel in std::execution,
but the query system was designed to support this usage. See
33.2.2
[exec.queryable.concept].
Most algorithms will want to dispatched based on where the operation
will complete successfully and would thus use the get_completion_domain<set_value_t>
query. To accommodate those algorithms that might want to dispatch
differently, this paper proposes to add a fourth form for the
get_completion_domain query: get_completion_domain<>
(without a completion tag parameter). See Addressing feedback from LEWG design
review for details about this query.
Just as the get_completion_domain
queries accept an optional env
argument, so too should the
get_completion_scheduler
queries.
connectWith the addition of the get_completion_domain<*>
queries that can accept the receiver’s environment,
connect can
now know the starting and completing domains of the async operation it
is constructing. When passed arguments
sndr and
rcvr, the starting domain is:
// Get the operation's starting domain: auto starting_domain = get_domain(get_env(rcvr));
To get the completion domain:
// Get the operation's completion domain: auto completion_domain = get_completion_domain<>(get_env(sndr), get_env(rcvr));
Now
connect has
all the information it needs to select the correct algorithm
implementation. Great!
But this presents the
connect
function with a dilemma: how does it use two domains to pick
one algorithm implementation?
Consider that the starting domain might want a say in how
start works, and the completing
domain might want a say in how
set_value works. So should we let
the starting domain customize start
and the completing domain customize
set_value?
No. start and
set_value are bookends around an
async operation; they must match. Often
set_value needs state that is set up
in start. Customizing the two
independently is madness.
The solution is to use sender transforms. Each domain can apply its transform in turn. I do not have a reason to believe the order matters, but it is important that when asked to transform a sender, a domain knows whether it is the “starting” domain or the “completing” domain.
Here is how a domain might customize
bulk when it is the completing
domain:
struct thread_pool_domain { template<sender-for<bulk_t> Sndr, class Env> auto transform_sender(set_value_t, Sndr&& sndr, const Env& env) const { //... } };
Since it has set_value_t as its
first argument, this transform is only applied when
thread_pool_domain is an operation’s
completion domain. Had the first argument been
start_t, the transform would only be
used when thread_pool_domain is a
starting domain.
transform_senderIn this proposed design, the
connect CPO
does a few things:
Determines the starting and completing domains,
Applies the completing domain’s transform (if any),
Applies the starting domain’s transform (if any) to the resulting sender,
Connnects the twice-transformed sender to the receiver.
The first three steps are doing something different than connecting a
sender and receiver, so it makes sense to factor them out into their own
utility. As it so happens we already have such a utility:
transform_sender.
The proposal requires some changes to how
transform_sender operates. This new
transform_sender still accepts a
sender and an environment, but it no longer accepts a domain. It
computes the two domains and applies the two transforms, recursing if a
transform changes the type of the sender.
A possible implementation of
transform_sender is listed in Appendix A:
Listing for updated transform_sender.
With the definition of
transform_sender in Appendix A,
connect(sndr, rcvr)
is equivalent to transform_sender(sndr, get_env(rcvr)).connect(rcvr)
(except rcvr is evaluated only
once).
Let’s see how this new approach addresses the problems noted in the motivating example above. The troublesome code is:
namespace ex = std::execution; auto sndr = ex::starts_on(gpu, ex::just()) | ex::then(fn); std::this_thread::sync_wait(std::move(sndr));
An illustrative example
describes how the current design and the “fixed” one proposed in [P3718R0] go off the rails while
determining the domain in which the function
fn will execute, causing it to use a
CPU implementation instead of a GPU one.
In the new design, when the then
sender is being connected to
sync_wait’s receiver, the starting
domain will still be the
default_domain, but when asking the
sender where it will complete, the answer will be different. Let’s see
how:
When asked for its completion domain, the
then sender will ask the
starts_on sender where it will
complete, as if by:
auto& [_, fn, child1] = *this; // *this is a then sender // child1 is a starts_on sender auto dom1 = ex::get_completion_domain<ex::set_value_t>(ex::get_env(child1), ex::get_env(rcvr));
In turn, the starts_on sender
asks the just sender where it will
complete, telling it where it will start. (This is the new
bit.) It looks like:
auto& [_, sch, child2] = *this; // *this is a starts_on sender // child2 is a just sender // ask for the scheduler's completion domain: auto sch_dom = ex::get_completion_domain<ex::set_value_t>(sch, get_env(rcvr)); // construct an env that reflects the fact that child2 will be started on sch: auto env2 = ex::env{ex::prop{ex::get_scheduler, sch}, ex::prop{ex::get_domain, sch_dom}, ex::get_env(rcvr)}; // pass the new env when asking child2 for its completion domain: auto dom2 = ex::get_completion_domain<ex::set_value_t>(ex::get_env(child2), env2);
The just sender, when asked
where it will complete, will respond with the domain on which it is
started. In other words, get_completion_domain<set_value_t>(get_env(just()), env2)
will return get_domain(env2),
which is sch_dom.
Having correctly determined that the
then sender will start on the
default domain and complete on the GPU domain,
connect can
select the right implementation for the
then algorithm. It does that as
follows:
auto&& env = ex::get_env(rcvr); return ex::transform_sender(forward<Sndr>(sndr), env).connect(forward<Rcvr>(rcvr));
The transform_sender call will
execute the following (simplified):
ex::default_domain().transform_sender( ex::start, gpu_domain().transform_sender(ex::set_value, sndr, env), env)
where gpu_domain is the domain of
the gpu scheduler. The
default_domain does not apply any
transformation to then senders, so
this expression reduces to:
gpu_domain().transform_sender(ex::set_value, sndr, ex::get_env(rcvr))
So in the new customization scheme, the GPU domain gets a crack at
transforming the then sender before
it is connected to a receiver, as it should.
continues_on and
schedule_fromOne of the uglier parts of the current algorithm customization design
is that it needs special case handling for the
continues_on and
schedule_from algorithms. The
proposed design gives us an opportunity to clean this up
significantly.
In order to transition between two execution contexts, each of which
may know nothing about the other, it is necessary to do it in two steps:
a transition from a context to the default domain, and a
transition from the default domain to another context. A
scheduler can customize either or both of these two steps by customizing
the continues_on and
schedule_from algorithms.
The customization of continues_on
is found using the completion domain of
sndr, making it the sanctioned way
to transition off of a context.
schedule_from finds its
customization using the domain of
sch, making it useful for
transitioning onto a context.
When not customized, connecting the sender continues_on(sndr, sch)
performs a switcheroo and connects schedule_from(sch, sndr)
instead. In that way, both the source and destination contexts get a say
in how the execution transfer is mediated.
What if a domain wants to customize
continues_on? Asking continues_on(sndr, sch)
for its completion domain will yield the domain of
sch, but
continues_on wants to use the
completion domain of sndr. The usual
transform_sender mechanism does not
seem to cut it.
This is handled in the current draft wording by making
continues_on a special case in
transform_sender. In [P3718R0], the special casing is
replaced with a get_domain_override
attribute query, by which the
continues_on sender can force
transform_sender to use a different
domain.
Both of these solutions are hacks.
A better way to solve this problem is to divide responsibilities
differently between continues_on and
schedule_from. Suppose that only
continues_on transfers execution,
and schedule_from does nothing and
only exists so it can be customized. The
continues_on customization point
would look like:
constexpr pipeable-adaptor continues_on =
[]<class Sndr, class Sch>(this auto self, Sndr&& sndr, Sch sch)
{
return make-sender(self, sch, schedule_from(forward<Sndr>(sndr)));
};The schedule_from customization
point would look like this:
constexpr auto schedule_from =
[]<class Sndr>(this auto self, Sndr&& sndr)
{
return make-sender(self, {}, forward<Sndr>(sndr));
};Semantically, schedule_from(sndr)
is equivalent to sndr. Crucially,
that means that schedule_from(sndr)
has the same completion domain as
sndr. And that makes
schedule_from a great way to
customize how to transition off of an execution context.
On the other hand, continues_on(sndr, sch)
completes on the domain of sch,
making it a great way to customize how to transition onto an
execution context.
By splitting continues_on and
schedule_from in this way, we
obviate the need for any special cases or domain overrides. The usual
transform_sender mechanism is
sufficient.
In the CCCL project, I
have implemented this design and ported my CUDA stream scheduler to use
it. I needed to customize
schedule_from for the CUDA stream
scheduler to mediate the execution transfer from the GPU back to the
CPU. Besides the bulk and
let algorithms,
schedule_from is the only algorithm
the GPU scheduler needs to customize.
NOTE Carving the two algorithms this way flips how
they are dispatched. continues_on
now dispatches based on the domain of
sch, and
schedule_from on the completion
domain of the predecessor sender. The original dispatching semantics
were chosen arbitrarily. The author believes the new
continues_on/schedule_from
dispatch semantics are more sensible.
inline_scheduler improvementsThe suggestion above to extend the get_completion_scheduler<*>
query presents an intriguing possibility for the
inline_scheduler: the ability for it
to report the scheduler on which its scheduling operations complete!
Consider the sender schedule(inline_scheduler()).
Ask it where it completes today and it will say, “I complete on the
inline_scheduler,” which isn’t
terribly useful. However, if you ask it, “Where will you complete – and
by the way you will be started on the
parallel_scheduler?”, now that
sender can report that it will complete on the
parallel_scheduler.
The result is that code that uses the
inline_scheduler will no longer
cause the actual scheduler to be hidden.
This realization is the motivation behind the change to strike the
get_completion_scheduler<set_value_t>(get_env(schedule(sch)))
requirement from the scheduler
concept. We want that expression to be ill-formed for the
inline_scheduler. Instead, we want
the following query to be well-formed:
get_completion_scheduler<set_value_t>(get_env(schedule(inline_scheduler())), get_env(rcvr))
That expression should be equivalent to get_scheduler(get_env(rcvr)),
which says that the sender of
inline_scheduler completes wherever
it is started.
When computing completion domains, it is sometimes the case that an
operation can complete on domain A
or domain B for a given disposition
(value, error, or stopped). Imagine such a sender with an indeterminate
completion domain for set_value. How
does algorithm customization work in that case?
First, we recognize that very few algorithms will ever be customized;
a given domain may only customize a handful. Given sndr | then(fn),
there is no difficulty picking the implementation for
then even if
sndr can complete successfully on
either domain A or
B, provided neither domain
customizes then.
That insight makes it advantageous for a sender to report
all the domains on which it might complete for a particular
completion channel. It can do that with a new domain type: indeterminate_domain<Domains...>,
which looks like this:
template<class... Domains> struct indeterminate_domain { template<class Tag, class Sndr, class Env> static constexpr auto transform_sender(Tag, Sndr&& sndr, const Env& env) { // Mandates: for all D in Domains, the expression // D().transform_sender(Tag(), forward<Sndr>(sndr), env) is either ill-formed or else // has the same type as // default_domain().transform_sender(Tag(), forward<Sndr>(sndr), env) return default_domain().transform_sender(Tag(), forward<Sndr>(sndr), env); } };
Given an environment e, a sender
like when_all(sndrs...)
would have a value completion domain of
COMMON-DOMAIN(COMPL-DOMAIN(set_value_t, sndrs, e)...)where:
is the type of COMPL-DOMAIN(T, S, E)get_completion_domain<T>(get_env(S), E)
if that expression is well-formed, or indeterminate_domain<>()
otherwise, and
is COMMON-DOMAIN(Ds...)common_type_t<Ds...>
if that expression is well-formed, and indeterminate_domain<Ds...>
otherwise.
The final piece is to specialize
common_type such that indeterminate_domain<As...>
and indeterminate_domain<Bs...>
have a common type of indeterminate_domain<As..., Bs...>,
and such that common_type_t<indeterminate_domain<As...>, D>
is indeterminate_domain<As..., D>.
The steps for fixing algorithm customization are detailed below.
Remove the uses of
transform_sender in the sender
adaptor algorithm customization points (33.9.12
[exec.adapt]).
Directly return the result of calling
make-sender
rather than passing it to
transform_sender.
Remove the exposition-only helpers:
completion-domain
(33.9.2
[exec.snd.expos]/8-9),get-domain-early
(33.9.2
[exec.snd.expos]/13),
andget-domain-late
(33.9.2
[exec.snd.expos]/14).Add the get_completion_domain
queries:
get_completion_domain<set_value_t>get_completion_domain<set_error_t>get_completion_domain<set_stopped_t>Change the
get_completion_scheduler queries to
accept an optional environment argument.
Make the get_domain(env)
query smarter by falling back to the current scheduler’s domain if env.query(get_domain)
is ill-formed, and falling back further to default_domain()
if env does not have a current
scheduler.
Restore the ability of env<...>::query
to accept additional arguments.
Rename the current
schedule_from algorithm to
continues_on and change it to return
,
where make-sender(continues_on, sch, schedule_from(sndr))schedule_from is a new
algorithm such that schedule_from(sndr)
is equivalent to .make-sender(schedule_from, {}, sndr)
Remove the (unused)
transform_env function and the
transform_env members of the sender
algorithm CPOs and from
default_domain.
Change transform_sender from
transform_sender(Domain, Sndr, Env...)
to transform_sender(Sndr, Env).
Have it compute the sender’s starting and completing domains and apply
their transforms to Sndr as shown in
Appendix A:
Listing for updated transform_sender.
Update the usages of
transform_sender in
connect and
get_completion_signatures to reflect
its new signature.
For the transform_sender
member functions in the sender algorithm CPOs, add
set_value_t, in the front of their
parameter list. Parameterize the
transform_sender member in
default_domain with a leading
Tag parameter.
Add a class template indeterminate_domain<Domains...>
as described in Indeterminate
domains.
Update the attributes of the sender algorithms to properly report
their completion schedulers and completion domains given an optional
env argument. Also update the
inline_scheduler and its
schedule-sender to compute their completion scheduler and domain from
the extra env argument.
From the scheduler concept,
replace the required expression
{ auto(get_completion_scheduler<set_value_t>(get_env(schedule(std::forward<Sch>(sch))))) } -> same_as<remove_cvref_t<Sch>>;
with a semantic requirement that if the above expression is
well-formed – which it is for the
parallel_scheduler, the
task_scheduler, and
run_loop’s scheduler – then it shall
compare equal to sch. (See inline_scheduler improvements
for the motivation behind these changes.)
For any scheduler sch and
completion tag Tag, require that the
expression get_completion_scheduler<Tag>(sch, env...),
if it is well-formed, has the same type and value as get_completion_scheduler<Tag>(get_env(schedule(sch)), env...).
Do likewise for the
get_completion_domain
queries.
[P3826R2] was reviewed by LEWG at the Fall 2025 meeting in Kona, HI. Two important issues with the proposed design were raised at that time, both by Robert Leahy:
There is a design tension between “non-dependent” senders and algorithm customization. Can a sender be non-dependent if a customization could cause the final sender to have a different set of completion signatures?
The proposed algorithm dispatch mechanism hard-codes the primacy
of the value channel.
transform_sender uses a sender’s
set_value completion domain to find
a customization. But some senders might want
transform_sender to use a different
domain to find a customization. How can that be expressed?
Let’s take these two issues separately.
A non-dependent sender is one whose completion signatures do not
depend on the receiver’s environment. Non-dependent senders were added
in [P3164R4] as a way to improve the
usability of std::execution by
allowing some sender expressions to be type-checked eagerly, upon
construction. just(42)
is an example of a non-dependent sender, whereas read_env(get_scheduler)
is dependent because the value it sends is the scheduler found in the
receiver’s environment.
By extension then(just(42), fn)
is also non-dependent, whereas then(read_env(get_scheduler), fn)
is dependent. The later expression should be well-formed
unconditionally, but the former should be ill-formed if
fn is not callable with an
int
argument, like
[]{} for
example.
But what if a customization of
then would make then(just(42), []{})
well-formed? Were we premature to reject the expression? Can
any customizable algorithm ever be non-dependent?
After lengthy discussions, Robert and I came to agree that the problem would be a non-issue if there were sufficient constraints on how a customization is allowed to change a sender’s completion signatures. In particular, a customization should not change a sender’s value completion signatures.
As it so happens, we are already requiring this of customizations. The following text is taken from 33.9.1 [exec.snd.general].
[…] For the default implementation of the algorithm that produced
sndr, connectingsndrtorcvrand starting the resulting operation state ([exec.async.ops]) necessarily results in the potential evaluation ([basic.def.odr]) of a set of completion operations whose first argument is a subexpression equal torcvr. LetSigsbe a pack of completion signatures corresponding to this set of completion operations, and letCSbe the type of the expressionget_completion_signatures<Sndr, Env>(). ThenCSis a specialization of the class templatecompletion_signatures(33.10 [exec.cmplsig]), the set of whose template arguments isSigs. […] If a user-provided implementation of the algorithm that producedsndris selected instead of the default:
- (1.1) Any completion signature that is in the set of types denoted by
completion_signatures_of_t<Sndr, Env>and that is not part ofSigsshall correspond to error or stopped completion operations, unless otherwise specified.
Since the current wording already requires customizations to preserve the value completion signatures of the original sender, no further changes are needed.
transform_sender, as proposed by
this paper, would use an operation’s starting and completing domain to
find customizations. But which completing domain, the value,
error, or stopped? R2 of this paper proposed to always use the
set_value completion domain.
But consider an algorithm like translate_error(sndr, fn)
which passes value and stopped completions through unchanged, but that
transforms errors with fn before
sending them on. This algorithm may want to dispatch based on where
fn will be called from, which would
be the error completion domain, not the value completion
domain.
After considering the issue, I decided that I agreed with Robert that the proposed design was deficient in this respect.
I propose that in addition to the following queries:
get_completion_domain<set_value_t>get_completion_domain<set_error_t>get_completion_domain<set_stopped_t>we also have:
get_completion_domain<>.get_completion_domain<>(attrs, env...)
would return attrs.query(get_completion_domain<>, env...)
if that is well-formed. Otherwise, it defaults to get_completion_domain<set_value_t>(attrs, env...).
transform_sender would determine
a sender’s completion domain by querying for get_completion_domain<>.
That way, a sender can implement that query to say, “For the purposes of
algorithm dispatching, use domain
D.” And if a sender does not
implement that query, the set_value
completion domain will be used instead.
Robert Leahy agrees that this change addresses his concern. This revision adds wording to that effect.
[ Editor's note: In 33.4 [execution.syn], make the following changes: ]
… as before … namespace std::execution { // [exec.queries], queries struct get_domain_t {unspecified}; struct get_scheduler_t {unspecified}; struct get_delegation_scheduler_t {unspecified}; struct get_forward_progress_guarantee_t {unspecified}; template<class CPO> struct get_completion_scheduler_t {unspecified};template<class CPO = void>struct get_completion_domain_t {struct get_await_completion_adaptor_t {unspecified};unspecified}; inline constexpr get_domain_t get_domain{}; inline constexpr get_scheduler_t get_scheduler{}; inline constexpr get_delegation_scheduler_t get_delegation_scheduler{}; enum class forward_progress_guarantee; inline constexpr get_forward_progress_guarantee_t get_forward_progress_guarantee{}; template<class CPO> constexpr get_completion_scheduler_t<CPO> get_completion_scheduler{};template<class CPO = void>constexpr get_completion_domain_t<CPO> get_completion_domain{};inline constexpr get_await_completion_adaptor_t get_await_completion_adaptor{}; struct get_env_t {unspecified}; inline constexpr get_env_t get_env{}; template<class T> using env_of_t = decltype(get_env(declval<T>())); // [exec.prop], class template prop template<class QueryTag, class ValueType> struct prop; // [exec.env], class template env template<queryable... Envs> struct env;// [exec.domain.indeterminate], execution domainstemplate<class... Domains>struct indeterminate_domain;// [exec.domain.default], execution domains struct default_domain; … as before … template<sender Sndr> using tag_of_t =see below; // [exec.snd.transform], sender transformations template<sender Sndr,class Domain,queryable…Env> requires (sizeof...(Env) <= 1) constexpr sender decltype(auto) transform_sender(Sndr&& sndr, const Env&Domain dom,env) noexcept(...see below);// [exec.snd.transform.env], environment transformationstemplate<class Domain, sender Sndr,queryableEnv>constexpr queryable decltype(auto) transform_env(// [exec.snd.apply], sender algorithm application template<class Domain, class Tag, sender Sndr, class... Args> constexpr decltype(auto) apply_sender( Domain dom, Tag, Sndr&& sndr, Args&&... args) noexcept(Domain dom, Sndr&& sndr, Env&& env) noexcept;see below); // [exec.connect], the connect sender algorithm struct connect_t; inline constexpr connect_t connect{}; … as before …
[ Editor's note: Before subsection 33.5.1 [exec.fwd.env], insert a new subsection with stable name [exec.queries.expos] as follows: ]
Query utilities [exec.queries.expos]
[exec.queries] makes use of the following exposition-only entities.
For subexpressions
qandtagand packargs, letbe expression-equivalent toTRY-QUERY(q, tag, args...)if that expression is well-formed, andAS-CONST(q).query(tag, args...)otherwise.AS-CONST(q).query(tag)For subexpressions
qandtagand packargs, letbe an objectHIDE-SCHED(q)osuch thato.query(tag, args...)is ill-formed when the decayed type oftagisget_scheduler_torget_domain_t, ando.query(tag, args...)otherwise.
[ Editor's note: Change [exec.get.domain] as follows: ]
execution::get_domain[exec.get.domain]
get_domainasks a queryable object for its associated execution domain tag.The name
get_domaindenotes a query object. For a subexpressionenv,get_domain(env)is expression-equivalent to, whereMANDATE-NOTHROW(D())Dis the type of the first of the following expressions that is well-formed [ Editor's note: Reformatted as a list. ]
- (2.1)
MANDATE-NOTHROW(auto(AS-CONST(env).query(get_domain))
forwarding_query(execution::get_domain)is a core constant expression and has valuetrue.
[ Editor's note: Change subsection 33.5.6 [exec.get.scheduler] as follows: ]
get_schedulerasks a queryable object for its associated scheduler.The name
get_schedulerdenotes a query object. For a subexpressionenv,get_scheduler(env)is expression-equivalent toget_completion_scheduler<set_value_t>(MANDATE-NOTHROW(AS-CONST(env).query(get_scheduler)),)HIDE-SCHED(env)Mandates: If the expression above is well-formed, its type satisfies
scheduler.
forwarding_query(execution::get_scheduler)is a core constant expression and has valuetrue.
[ Editor's note: Change subsection 33.5.9 [exec.get.compl.sched] as follows: ]
execution::get_completion_scheduler[exec.get.compl.sched]
get_completion_scheduler<obtains the completion scheduler associated with a completion tag from a sender’s attributes.completion-tag>The name
get_completion_schedulerdenotes a query object template. For a subexpressionqand packenvs, the expressionget_completion_scheduler<is ill-formed ifcompletion-tag>(q, envs...)completion-tagis not one ofset_value_t,set_error_t, orset_stopped_t. Otherwise,get_completion_scheduler<is expression-equivalent tocompletion-tag>(q, envs...)MANDATE-NOTHROW(AS-CONST(q).query(get_completion_scheduler<completion-tag>))
(3.1)
if that expression is well-formed.MANDATE-NOTHROW(RECURSE-QUERY(TRY-QUERY(q, get_completion_scheduler<completion-tag>, envs...), envs...))(3.2) Otherwise,
auto(q)if the type ofqsatisfiesschedulerandsizeof...(envs) != 0istrue.(3.3) Otherwise,
get_completion_scheduler<is ill-formed.completion-tag>(q, envs...)Mandates: If
the expression aboveget_completion_scheduler<is well-formed, its type satisfiescompletion-tag>(q, envs...)scheduler.
- For a type
Tag, subexpressionsndr, and packenv, letCSbecompletion_signatures_of_t<decay_t<decltype((sndr))>, decltype((env))...>. If bothget_completion_scheduler<Tag>(get_env(sndr), env...)andCSare well-formed andCS().iscount-of(Tag()) == 0true, the program is ill-formed.
Let
completion-fnbe a completion function (33.3 [exec.async.ops]); letcompletion-tagbe the associated completion tag ofcompletion-fn; letargsandenvsbeapacks of subexpressions; and letsndrbe a subexpression such thatsender<decltype((sndr))>istrueandget_completion_scheduler<is well-formed and denotes a schedulercompletion-tag>(get_env(sndr), envs...)sch. If an asynchronous operation created by connectingsndrwith a receiverrcvrcauses the evaluation of, the behavior is undefined unless the evaluation happens on an execution agent that belongs tocompletion-fn(rcvr, args...)sch’s associated execution resource.The expression
forwarding_query(get_completion_scheduler<is a core constant expression and has valuecompletion-tag>)true.
[ Editor's note: After subsection 33.5.9 [exec.get.compl.sched], add a new subsection with stable name [exec.get.compl.domain] as follows. ]
execution::get_completion_domain[exec.get.compl.domain]
get_completion_domain<obtains the completion domain associated with a completion tag from a sender’s attributes.completion-tag>The name
get_completion_domaindenotes a query object template. For a subexpressionoand packenv, the expressionget_completion_domain<is ill-formed ifcompletion-tag>(o, env...)completion-tagis not one ofvoid,set_value_t,set_error_t, orset_stopped_t. Otherwise,get_completion_domain<is expression-equivalent tocompletion-tag>(o, env...), whereMANDATE-NOTHROW(D())Dis:
(2.1) The type of
if that expression is well-formed.TRY-QUERY(o, get_completion_domain<completion-tag>, env...)(2.2) Otherwise, the type of
get_completion_domain<set_value_t>(o, env...)ifcompletion-tagisvoid.(2.3) Otherwise, the type of
if that expression is well-formed.TRY-QUERY(get_completion_scheduler<completion-tag>(o, env...), get_completion_domain<set_value_t>, env...)(2.4) Otherwise,
default_domainifscheduler<decltype((o))> && sizeof...(env) != 0istrue.(2.5) Otherwise,
get_completion_domain<is ill-formed.completion-tag>(o, env...)For a type
Tag, subexpressionsndr, and packenv, letCSbecompletion_signatures_of_t<decay_t<decltype((sndr))>, decltype((env))...>. If bothget_completion_domain<Tag>(get_env(sndr), env...)andCSare well-formed andCS().iscount-of(Tag()) == 0true, the program is ill-formed.Let
completion-fnbe a completion function ([exec.async.ops]); letcompletion-tagbe the associated completion tag ofcompletion-fn; letargsandenvbe packs of subexpressions; and letsndrbe a subexpression such thatsender<decltype((sndr))>istrueandget_completion_domain<is well-formed and denotes a domaincompletion-tag>(get_env(sndr), env...)D. If an asynchronous operation created by connectingsndrwith a receiverrcvrcauses the evaluation of, the behavior is undefined unless the evaluation happens on an execution agent of an execution resource whose associated execution domain tag iscompletion-fn(rcvr, args...)D.The expression
forwarding_query(get_completion_domain<is a core constant expression and has valuecompletion-tag>)true.
[ Editor's note: In 33.6 [exec.sched], change paragraphs 1, 5, and 6 as follows: ]
The
schedulerconcept defines the requirements of a scheduler type (33.3 [exec.async.ops]).scheduleis a customization point object that accepts a scheduler. A valid invocation ofscheduleis a schedule-expression.namespace std::execution { template<class Sch> concept scheduler = derived_from<typename remove_cvref_t<Sch>::scheduler_concept, scheduler_t> && queryable<Sch> && requires(Sch&& sch) { { schedule(std::forward<Sch>(sch)) } -> sender;{ auto(get_completion_scheduler<set_value_t>(get_env(schedule(std::forward<Sch>(sch))))) }} && equality_comparable<remove_cvref_t<Sch>> && copyable<remove_cvref_t<Sch>>; }-> same_as<remove_cvref_t<Sch>>;… as before …
For a given scheduler expression
sch, if the expressionget_completion_scheduler<set_value_t>(get_env(schedule(sch)))is well-formed, it shall compare equal tosch.For a given scheduler expression
sch, typeT, and pack of subexpressionsenv,if the expressionthe following two expressions are either both ill-formed, or both well-formed with the same type:get_domain(sch)is well-formed, then the expressionget_domain(get_env(schedule(sch)))is also well-formed and has the same type.… as before …
[ Editor's note: Change 33.9.1 [exec.snd.general] as follows: ]
Subclauses 33.9.11
[exec.factories]
and 33.9.12
[exec.adapt] define
customizable algorithms that return senders. Each algorithm has a
default implementation. Let sndr be
the result of an invocation of such an algorithm or an object equal to
the result (18.2
[concepts.equality]),
and let Sndr be decltype((sndr)).
Let rcvr be a receiver of type
Rcvr with associated environment
env of type
Env such that sender_to<Sndr, Rcvr>
is true. For
the default implementation of the algorithm that produced
sndr, connecting
sndr to
rcvr and starting the resulting
operation state (33.3
[exec.async.ops])
necessarily results in the potential evaluation (6.3
[basic.def.odr]) of
a set of completion operations whose first argument is a subexpression
equal to rcvr. [ Editor's note: Broken into a separate
paragraph: ]
Let Sigs be a pack of
completion signatures corresponding to this set of completion
operations, and let CS be the type
of the expression get_completion_signatures<Sndr, Env>().
Then CS is a specialization of the
class template completion_signatures
(33.10
[exec.cmplsig]), the
set of whose template arguments is
Sigs. If none of the types in
Sigs are dependent on the type
Env, then the expression get_completion_signatures<Sndr>()
is well-formed and its type is
CS.
Each completion operation can potentially be evaluated on one of
several different execution agents as determined by the semantics of the
algorithm, the environment of the receiver, and the completions of any
child senders. For a completion tag
T, let
CsT be the
set of domain tags associated with the execution agents that could
potentially evaluate any of the operation’s completions with tag
T, and let
DsT be a
pack corresponding to
CsT. If
there are no potentially evaluated completion operations with tag type
T, then get_completion_domain<T>(get_env(sndr), env)
is ill-formed; otherwise, it has type
(33.9.2
[exec.snd.expos]).COMMON-DOMAIN<DsT...>
[ Example: Let
S be the sender
then(sndr, fn).
S has the same
set_value completion domain as
sndr, but if
fn’s evaluation is potentially
throwing, S’s
set_error completion domain
would be the
COMMON-DOMAIN of
sndr’s value and error
completion domains, in accordance with the semantics of the
then algorithm (33.9.12.9
[exec.then]). —
end example ]
If sndr can determine
that all of its completion operations with tag
T happen on execution agents
associated with a particular scheduler
S (as determined by the
semantics of the algorithm, the environment of the receiver, and the
completion schedulers of any child senders), then get_completion_scheduler<T>(get_env(sndr), env)
is well-formed and has the type and value of
S; otherwise, it is
ill-formed.
[ Example: Let
S be the sender from the example
above. The set_value completion
scheduler of S is the
set_value completion scheduler
of sndr, if any. But
S can only report a
set_error completion scheduler
when invocations of fn are not
potentially throwing or when
sndr has no
set_error completions. When
fn can throw,
S could complete with
set_error either by forwarding
an error completion from sndr or
by completing with the exception thrown by
fn, which would happen on an
agent associated with sndr’s
set_value completion
scheduler. — end example ]
[ Editor's note: Broken into a separate paragraph: ]
If a user-provided implementation of the algorithm that produced
sndr is selected instead of the
default:
(1.1) Any
completion signature that is in the set of types denoted by completion_signatures_of_t<Sndr, Env>
and that is not part of Sigs shall
correspond to error or stopped completion operations, unless otherwise
specified.
(1.2) If
none of the types in Sigs are
dependent on the type Env, then
completion_signatures_of_t<Sndr>
and completion_signatures_of_t<Sndr, Env>
shall denote the same type.
Various function templates in subclause 33.9
[exec.snd] can throw an
exception of type unspecified-exception.
Each such exception object is of an unspecified type such that a handler
of type exception matches
(14.4
[except.handle])
the exception object but a handler of type
dependent_sender_error does not.
[ Note: There is no requirement that two such exception objects have the same type. — end note ]
[ Editor's note: Change 33.9.2 [exec.snd.expos] paragraph 3 as follows: ]
- For a query object
qand, a subexpressionv, and a pack of subexpressionsas,is an expressionMAKE-ENV(q, v)envwhose type satisfiesqueryablesuch that the result ofenv.query(qhas a value equal to, as...)v(18.2 [concepts.equality]). Unless otherwise stated, the object to whichenv.query(qrefers remains valid while, as...)envremains valid.
[ Editor's note: Before 33.9.2 [exec.snd.expos] paragraph 6, add two new paragraphs as follows: ]
For a pack of subexpressions
domains,is expression-equivalent toCOMMON-DOMAIN(domains...)common_type_t<decltype(auto(domains))...>()if that expression is well-formed, andindeterminate_domain<Ds...>()otherwise, whereDsis the pack of types consisting ofdecltype(auto(domains))...with duplicate types removed.For a type
Tag, subexpressionsndr, and packenv,is expression-equivalent toCOMPL-DOMAIN(Tag, sndr, env)D()whereDis the type ofget_completion_domain<Tag>(get_env(sndr), env...)if that expression is well-formed or ifsizeof...(env) == 0istrue, andindeterminate_domain()otherwise.
[ Editor's note: Change
33.9.2
[exec.snd.expos]
paragraph 6 (renumbered to 8) about
SCHED-ATTRS and
SCHED-ENV as follows:
]
For a schedulersch,is an expression o1 whose type satisfiesSCHED-ATTRS(sch)queryablesuch thato1.query(get_completion_scheduler<Tag>)is an expression with the same type and value asschwhereTagis one ofset_value_torset_stopped_t, and such thato1.query(get_domain)is expression-equivalent tosch.query(get_domain).is an expressionSCHED-ENV(sch)o2whose type satisfiesqueryablesuch thato2.query(get_scheduler)is a prvalue with the same type and value assch, and such thato2.query(get_domain)is expression-equivalent tosch.query(get_domain).
[ Editor's note: Remove
the prototype of the exposition-only
completion-domain
function just before 33.9.2
[exec.snd.expos]
paragraph 8, and with it remove paragraphs 8 and 9, which specify the
function’s behavior. ]
[ Editor's note: Remove
33.9.2
[exec.snd.expos]
paragraphs 13 and 14 and the prototypes for the
get-domain-early and
get-domain-late
functions. ]
[ Editor's note: After
33.9.2
[exec.snd.expos]
paragraph 26, change the declaration of the exposition-only class
default-impls as
follows: ]
struct default-impls { // exposition only
static constexpr auto get-attrs = see below; // exposition only
static constexpr auto get-env = see below; // exposition only
static constexpr auto get-state = see below; // exposition only
static constexpr auto start = see below; // exposition only
static constexpr auto complete = see below; // exposition only
template<class Sndr, class... Env>
static consteval void check-types(); // exposition only
};[ Editor's note: Strike 33.9.2 [exec.snd.expos] paragraph 35 as follows: ]
The member
is initialized with a callable object equivalent to the following lambda:default-impls::get-attrs[](const auto&, const auto&... child) noexcept -> decltype(auto) { if constexpr (sizeof...(child) == 1) return (FWD-ENV(get_env(child)), ...); else return env<>(); }
[ Editor's note: After
33.9.2
[exec.snd.expos]
paragraph 47
(not-a-sender), add the
following new paragraph ]
structnot-a-scheduler{ using scheduler_concept = scheduler_t; constexpr auto schedule() const noexcept { returnnot-a-sender(); } };
[ Editor's note: Add the following new paragraphs after 33.9.2 [exec.snd.expos] paragraph 50 as follows: ]
template<class Fn, class Default, class... Args> constexpr autocall-with-default(Fn&& fn, Default&& value, Args&&... args) noexcept(see below);
Let
ebe the expressionstd::forward<Fn>(fn)(std::forward<Args>(args)...)if that expression is well-formed; otherwise, it isstatic_cast<Default>(std::forward<Default>(value)).Returns:
e.Remarks: The expression in the
noexceptclause isnoexcept(e).template<class Tag> structinline-attrs{see below};For a subexpression
env,is expression-equivalent toinline-attrs<Tag>{}.query(get_completion_scheduler<Tag>, env)get_scheduler(env).For a subexpression
env,is expression-equivalent toinline-attrs<Tag>{}.query(get_completion_domain<Tag>, env)get_domain(env).
[ Editor's note: Add a new subsection before [exec.domain.default] with stable name [exec.domain.indeterminate] as follows: ]
33.9.?
execution::indeterminate_domain[exec.domain.indeterminate]
namespace std::execution { template<class... Domains> struct indeterminate_domain { indeterminate_domain() = default; constexpr indeterminate_domain(auto&&) noexcept {} template<class Tag, sender Sndr,queryableEnv> static constexpr sender decltype(auto) transform_sender(Tag, Sndr&& sndr, const Env& env) noexcept(see below); }; }template<class Tag, sender Sndr,queryableEnv> static constexpr sender decltype(auto) transform_sender(Tag, Sndr&& sndr, const Env& env) noexcept(see below);
Mandates: For each type
DinDomains..., the expressionD().transform_sender(Tag(), std::forward<Sndr>(sndr), env)is either ill-formed or has the same decayed type asdefault_domain().transform_sender(Tag(), std::forward<Sndr>(sndr), env).Returns:
default_domain().transform_sender(Tag(), std::forward<Sndr>(sndr), env)Remarks: For a pack of types
Ds,common_type_t<indeterminate_domain<Domains...>, indeterminate_domain<Ds...>>isindeterminate_domain<Us...>whereUsis the pack of types inDomains..., Ds...except with duplicate types removed. For a typeDthat is not a specialization ofindeterminate_domain,common_type_t<indeterminate_domain<Domains...>, D>isDifsizeof...(Domains) == 0istrue, andcommon_type_t<indeterminate_domain<Domains...>, indeterminate_domain<D>>otherwise.
[ Editor's note: Change 33.9.5 [exec.domain.default] as follows: ]
33.9.5
execution::default_domain[exec.domain.default]
namespace std::execution { struct default_domain { template<class Tag, sender Sndr,queryableEnv>...static constexpr sender decltype(auto) transform_sender(requires (sizeof...(Env) <= 1)Tag,Sndr&& sndr, const Env&env) noexcept(...see below);template<sender Sndr,queryableEnv>template<class Tag, sender Sndr, class... Args> static constexpr decltype(auto) apply_sender(Tag, Sndr&& sndr, Args&&... args) noexcept(static constexprqueryabledecltype(auto) transform_env(Sndr&& sndr, Env&& env) noexcept;see below); }; }template<class Tag, sender Sndr,queryableEnv>...static constexpr sender decltype(auto) transform_sender(requires (sizeof...(Env) <= 1)Tag,Sndr&& sndr, const Env&env) noexcept(...see below);
Let
ebe the expressiontag_of_t<Sndr>().transform_sender(Tag(),std::forward<Sndr>(sndr), env)...if that expression is well-formed; otherwise,
. [ Editor's note: See https://cplusplus.github.io/LWG/issue4368 for why thestatic_cast<Sndr>(std::forward<Sndr>(sndr))static_castis necessary. ]Returns:
e.Remarks: The exception specification is equivalent to
noexcept(e).template<sender Sndr,queryableEnv> constexprqueryabledecltype(auto) transform_env(Sndr&& sndr, Env&& env) noexcept;
Let e be the expression
tag_of_t<Sndr>().transform_env(std::forward<Sndr>(sndr), std::forward<Env>(env))if that expression is well-formed; otherwise,
.FWD-ENV(std::forward<Env>(env))Mandates:
noexcept(e)istrue.Returns:
e.template<class Tag, sender Sndr, class... Args> constexpr decltype(auto) apply_sender(Tag, Sndr&& sndr, Args&&... args) noexcept(see below);
Let
ebe the expressionTag().apply_sender(std::forward<Sndr>(sndr), std::forward<Args>(args)...)Constraints:
eis a well-formed expression.Returns:
e.Remarks: The exception specification is equivalent to
noexcept(e).
[ Editor's note: Change 33.9.6 [exec.snd.transform] as follows: ]
execution::transform_sender[exec.snd.transform]namespace std::execution { template<sender Sndr,class Domain,queryableEnv>...constexpr sender decltype(auto) transform_sender(requires (sizeof...(Env) <= 1)Sndr&& sndr, const Env&Domain dom,env) noexcept(...see below); }
For a subexpression
s, letbedomain-for(start, s)D()whereDis the decayed type ofget_domain(env)if that expressions that is well-formed, anddefault_domainotherwise.Let
bedomain-for(set_value, s)D()whereDis the decayed type ofget_completion_domain<>(get_env(sndr), env)if that is well-formed, anddefault_domainotherwise.
Let
be the expressiontransformed-sndr(dom, tag, s)dom.transform_sender(std::forward<Sndr>(sndr), env...)dom.transform_sender(tag, s, env)if that expression is well-formed; otherwise,
default_domain().transform_sender(std::forward<Sndr>(sndr), env...)default_domain().transform_sender(tag, s, env)Let
final-sndrbe the expressiontransform-recurse(dom, tag, s)iftransformed-sndr(dom, tag, s)andtransformed-sndr(dom, tag, s)sndrshave the same type ignoringcv-qualifiers; otherwise, it is the expressiontransform_sender(dom,transformed-sndr, env...)wheretransform-recurse(dom2, tag, s2)s2isandtransformed-sender(dom, tag, s)dom2is.domain-for(tag, s2)Let
tmp-sndrbe the expressiontransform-recurse(domain-for(set_value, sndr), set_value, sndr)and let
final-sndrbe the expressiontransform-recurse(domain-for(start,tmp-sndr), start,tmp-sndr)Returns:
final-sndr.Remarks: The exception specification is equivalent to
noexcept(.final-sndr)
[ Editor's note: Remove section 33.9.7 [exec.snd.transform.env]. ]
[ Editor's note: Change 33.9.9 [exec.getcomplsigs] paragraphs 1 and 4 as follows: ]
template<class Sndr, class... Env> consteval auto get_completion_signatures() ->valid-completion-signaturesauto;
Let
exceptbe an rvalue subexpression of an unspecified class typeExceptsuch thatmove_constructible<isExcept> && derived_from<Except, exception>true. LetbeCHECKED-COMPLSIGS(e)eifeis a core constant expression whose type satisfiesvalid-completion-signatures; otherwise, it is the following expression:(Lete, throwexcept, completion_signatures())be expression-equivalent toget-complsigs<Sndr, Env...>()remove_reference_t<Sndr>::template get_completion_signatures<Sndr, Env...>(). LetNewSndrbeSndrifsizeof...(Env) == 0istrue; otherwise,decltype(wheres)sis the following expression:transform_sender(declval<Sndr>(), declval<Env>()...)get-domain-late(declval<Sndr>(), declval<Env>()...),… as before …
… as before …
Given a type
Env, ifcompletion_signatures_of_t<Sndr>andcompletion_signatures_of_t<Sndr, Env>are both well-formed,they shall denote the same typethe latter shall be a superset of the former, with completion signatures that are incompletion_signatures_of_t<Sndr, Env>but notcompletion_signatures_of_t<Sndr>corresponding to error or stopped completion operations.
[ Editor's note: Change 33.9.10 [exec.connect] paragraph 2 as follows: ]
The name
connectdenotes a customization point object. For subexpressionssndrandrcvr, letSndrbedecltype((sndr))andRcvrbedecltype((rcvr)), letnew_sndrbe the expressiontransform_sender(sndr, get_env(rcvr))decltype(get-domain-late(sndr, get_env(rcvr))){},and let
DSandDRbedecay_t<decltype((new_sndr))>anddecay_t<Rcvr>, respectively.
[ Editor's note: Remove 33.9.11.1 [exec.schedule] paragraph 4 as follows: ]
If the expression
get_completion_scheduler<set_value_t>(get_env(sch.schedule())) == schis ill-formed or evaluates to
false, the behavior of callingschedule(sch)is undefined.
[ Editor's note: Change 33.9.12.1 [exec.adapt.general] paragraph 3.2-3 as follows: ]
(3.2) A parent sender (33.3 [exec.async.ops]) with a single child sender
sndrhas an associated attribute object equal to(33.5.1 [exec.fwd.env]) modulo the handling of theFWD-ENV(get_env(sndr))get_completion_scheduler<andcompletion-tag>get_completion_domain<queries as described in [exec.snd.general].completion-tag>(3.3) A parent sender with more than one child sender has an associated attributes object equal to
env<>{}modulo the handling of theget_completion_scheduler<andcompletion-tag>get_completion_domain<queries as described in [exec.snd.general].completion-tag>
[ Editor's note: Change 33.9.12.5 [exec.starts.on] paragraphs 3 and 4, and insert a new paragraph 5 as follows: ]
Otherwise, the expression
starts_on(sch, sndr)is expression-equivalent to:transform_sender(query-with-default(get_domain, sch, default_domain()),make-sender(starts_on, sch, sndr))
except thatschis evaluated only once.Let
out_sndrand env be subexpressions such thatOutSndrisdecltype((out_sndr)). Ifissender-for<OutSndr, starts_on_t>false, then the expressionsstarts_on.transform_env(out_sndr, env)andstarts_on.transform_sender(set_value,out_sndr, env)areis ill-formed; otherwise
- (4.1)
starts_on.transform_env(out_sndr, env)is equivalent to:auto&& [_, sch, _] = out_sndr; returnJOIN-ENV(SCHED-ENV(sch),FWD-ENV(env));
- (4.2)
starts_on.transform_sender(is equivalent to:set_value,out_sndr, env)auto&& [_, sch, sndr] = out_sndr; return let_value(schedule(sch),continues_on(just(), sch),[sndr = std::forward_like<OutSndr>(sndr)]() mutable noexcept(is_nothrow_move_constructible_v<decay_t<OutSndr>>) { return std::move(sndr); });
[ Editor's note: Remove subsection 33.9.12.6 [exec.continues.on] ]
[ Editor's note: Change stable name 33.9.12.7 [exec.schedule.from] to [exec.continues.on], and change the subsection as follows: ]
33.9.12.
76execution::[execschedule_fromcontinues_on.schedule.from.continues.on]
schedule_fromcontinues_onschedules work dependent on the completion of a sender onto a scheduler’s associated execution resource.
[Note 1:schedule_fromis not meant to be used in user code; it is used in the implementation ofcontinues_on. — end note]The name
schedule_fromcontinues_ondenotes a customization point object. For some subexpressionsschandsndr, letSchbedecltype((sch))andSndrbedecltype((sndr)). IfSchdoes not satisfy scheduler, orSndrdoes not satisfysender,schedule_from(sch, sndr)continues_on(sndr, sch)is ill-formed.Otherwise, the expression
schedule_from(sch, sndr)continues_on(sndr, sch)is expression-equivalent to:make-sender(continues_on, sch, schedule_from(sndr))transform_sender(query-with-default(get_domain, sch, default_domain()),make-sender(schedule_from, sch, sndr))except that sch is evaluated only once.
The exposition-only class template
impls-for(33.9.1 [exec.snd.general]) is specialized forschedule_from_tcontinues_on_tas follows:namespace std::execution { template<> structimpls-for<schedule_from_tcontinues_on_t> :default-impls{static constexpr autostatic constexpr autoget-attrs=see below;get-state=see below; static constexpr autocomplete=see below; template<class Sndr, class... Env> static consteval voidcheck-types(); }; }
The member
is initialized with a callable object equivalent to the following lambda:impls-for<schedule_from_t>::get-attrs[](const auto& data, const auto& child) noexcept -> decltype(auto) { returnJOIN-ENV(SCHED-ATTRS(data),FWD-ENV(get_env(child))); }
The member
is initialized with a callable object equivalent to the following lambda:impls-for<schedule_from_tcontinues_on_t>::get-state… as before …
… as before …
The member
is initialized with a callable object equivalent to the following lambda:impls-for<schedule_from_tcontinues_on_t>::complete… as before …
Let
out_sndrbe a subexpression denoting a sender returned fromschedule_from(sch, sndr)continues_on(sndr, sch)or one equal to such, and letOutSndrbe the typedecltype((out_sndr)). Letout_rcvrbe … as before …
[ Editor's note: After 33.9.12.6 [exec.continues.on], add a new subsection with stable name [exec.schedule.from] as follows: ]
execution::schedule_from[exec.schedule.from]
schedule_fromoffers scheduler authors a way to customize how to transition off of their schedulers’ associated execution contexts.[ Note:
schedule_fromis not meant to be used in user code; it is used in the implementation ofcontinues_on. — end note ]The name
schedule_fromdenotes a customization point object. For some subexpressionsndr, ifdecltype(sndr)does not satisfysender,schedule_from(sndr)is ill-formed.Otherwise, the expression
schedule_from(sndr)is expression-equivalent to.make-sender(schedule_from, {}, sndr)
[ Editor's note: Change 33.9.12.8 [exec.on] as follows: ]
execution::on[exec.on]
The
onsender adaptor has two forms … as before …The name
ondenotes a … as before …Otherwise, if
decltype((sndr))satisfiessender, the expressionon(sch, sndr)is expression-equivalent to:transform_sender(make-sender(on, sch, sndr)query-with-default(get_domain, sch, default_domain()),)
except thatschis evaluated only once.For subexpressions
sndr,sch, andclosure, if
- (4.1)
decltype((sch))does not satisfyscheduler, or- (4.2)
decltype((sndr))does not satisfysender, or- (4.3)
closureis not a pipeable sender adaptor closure object (33.9.12.2 [exec.adapt.obj]),the expression
on(sndr, sch, closure)is ill-formed; otherwise, it is expression-equivalent to:transform_sender(make-sender(on,get-domain-early(sndr),product-type{sch, closure}, sndr))
except thatsndris evaluated only once.Let
out_sndrandenvbe subexpressions, letOutSndrbedecltype((out_sndr)), and letEnvbedecltype((env)). Ifissender-for<OutSndr, on_t>false, then the expressionson.transform_env(out_sndr, env)andon.transform_sender(set_value,out_sndr, env)areis ill-formed.
Otherwise: Let
not-a-schedulerbe an unspecified empty class type.The expression
on.transform_env(out_sndr, env)has effects equivalent to:auto&& [_, data, _] = out_sndr; if constexpr (scheduler<decltype(data)>) { returnJOIN-ENV(SCHED-ENV(std::forward_like<OutSndr>(data)),FWD-ENV(std::forward<Env>(env))); } else { return std::forward<Env>(env); }
Otherwise,
Tthe expressionon.transform_sender(set_value,out_sndr, env)has effects equivalent to:auto&& [_, data, child] = out_sndr; if constexpr (scheduler<decltype(data)>) { auto orig_sch =querycall-with-default(get_scheduler,, envnot-a-scheduler(), env);if constexpr (same_as<decltype(orig_sch),not-a-scheduler>) {returnnot-a-sender{};return continues_on( starts_on(std::forward_like<OutSndr>(data), std::forward_like<OutSndr>(child)), std::move(orig_sch));} else {} else { auto& [sch, closure] = data; auto orig_sch =}querycall-with-default( get_completion_scheduler<set_value_t>,not-a-scheduler(), get_env(child), env);get_env(child),query-with-default(get_scheduler, env,not-a-scheduler()));if constexpr (same_as<decltype(orig_sch),not-a-scheduler>) {returnnot-a-sender{};return} else {write_envcontinues_on(continues_onwrite_env( std::forward_like<OutSndr>(closure)( continues_on( write_env(std::forward_like<OutSndr>(child),SCHED-ENV(orig_sch)), sch)),orig_sch),SCHED-ENV(sch)SCHED-ENV(sch)orig_sch);}}
[ Editor's note: Change 33.9.12.9 [exec.then] paragraphs 3 as follows: ]
Otherwise, the expression
is expression-equivalent to:then-cpo(sndr, f)transform_sender(get-domain-early(sndr),make-sender(then-cpo, f, sndr))
except thatsndris evaluated only once.
[ Editor's note: Change 33.9.12.10 [exec.let] as follows: ]
let_value,let_error, andlet_stopped… as before …For
let_value,let_error, andlet_stopped, letset-cpobeset_value,set_error, andset_stopped, respectively. Let the expressionlet-cpobe one oflet_value,let_error, orlet_stopped. Forasubexpressionssndrandenv, letbe expression-equivalent to the first well-formed expression below:let-env(sndr, env)
- (2.1)
SCHED-ENV(get_completion_scheduler<decayed-typeof<set-cpo>>(get_env(sndr),FWD-ENV(env)))
- (2.2)
MAKE-ENV(get_domain, get_domain(get_env(sndr)))
- (2.2)
MAKE-ENV(get_domain, get_completion_domain<decayed-typeof<set-cpo>>(get_env(sndr),FWD-ENV(env)))
- (2.3)
(void(sndr), env<>{})The names
let_value,let_error, andlet_stoppeddenote … as before …Otherwise, the expression
is expression-equivalent to:let-cpo(sndr, f)transform_sender(get-domain-early(sndr),make-sender(let-cpo, f, sndr))
except thatsndris evaluated only once.The exposition-only class … as before …
Let
receiver2denote the following exposition-only class template:namespace std::execution { template<class Rcvr, class Env> structreceiver2{ … as before … }; }Invocation of the function
returns an object e such thatreceiver2::get_env
(6.1)
decltype(e)modelsqueryableand(6.2) given a query object
qand pack of subexpressionsas, the expressione.query(qis expression-equivalent to, as...)env.query(qif that expression is valid; otherwise, if the type of, as...)qsatisfiesforwarding-query,e.query(qis expression-equivalent to, as...)get_env(rcvr).query(q; otherwise,, as...)e.query(qis ill-formed., as...)Effects: Equivalent to:
… as before …
where
env-tis the packdecltype(let-cpo.transform_env(declval<Sndr>(), declval<Env>()))decltype(.JOIN-ENV(let-env(declval<child-type<Sndr>>(), declval<Env>()),FWD-ENV(declval<Env>())))
is initialized with a callable object equivalent to the following:impls-for<decayed-typeof<let-cpo>>::get-state[]<class Sndr, class Rcvr>(Sndr&& sndr, Rcvr& rcvr) requiressee below{ auto& [_, fn, child] = sndr; using fn_t = decay_t<decltype(fn)>; using env_t = decltype(let-env(child, get_env(rcvr))); using args_variant_t =see below; using ops2_variant_t =see below; structstate-type{ fn_t fn; // exposition only env_t env; // exposition only args_variant_t args; // exposition only ops2_variant_t ops2; // exposition only }; returnstate-type{allocator-aware-forward(std::forward_like<Sndr>(fn), rcvr),let-env(child, get_env(rcvr)), {}, {}}; }[ Editor's note: leave paragraphs 9-13 unchanged ]
Let
sndrandenvbe subexpressions, and letSndrbedecltype((sndr)). Ifissender-for<Sndr,decayed-typeof<let-cpo>>false, then the expressionis ill-formed. Otherwise, it is equal to:let-cpo.transform_env(sndr, env)auto& [_, _, child] = sndr; returnJOIN-ENV(let-env(child),FWD-ENV(env));
- Let the subexpression
out_sndrdenote … as before …
[ Editor's note: Change 33.9.12.11 [exec.bulk] paragraph 3 and 4 as follows: ]
Otherwise, the expression
is expression-equivalent to:bulk-algo(sndr, policy, shape, f)transform_sender(get-domain-early(sndr),make-sender(bulk-algo,product-type<see below, Shape, Func>{policy, shape, f}, sndr))
except thatsndris evaluated only once.The first template argument of
product-typeisPolicyifPolicymodelscopy_constructible, andconst Policy&otherwise.Let
sndrandenvbe subexpressions such thatSndrisdecltype((sndr)). Ifissender-for<Sndr, bulk_t>false, then the expressionbulk.transform_sender(is ill-formed; otherwise, it is equivalent to:set_value,sndr, env)auto [_, data, child] = sndr; auto& [policy, shape, f] = data; auto new_f = [func = std::move(f)](Shape begin, Shape end, auto&&... vs) noexcept(noexcept(f(begin, vs...))) { while (begin != end) func(begin++, vs...); } return bulk_chunked(std::move(child), policy, shape, std::move(new_f));[ Note: This causes the
bulk(sndr, policy, shape, f)sender to be expressed in terms ofbulk_chunked(sndr, policy, shape, f)when it is connected to a receiver whose execution domain does not customizebulk. — end note ]
[ Editor's note: Change 33.9.12.12 [exec.when.all] paragraphs 2 and 3 as follows: ]
The names
when_allandwhen_all_with_variantdenote customization point objects. Letsndrsbe a pack of subexpressions,and letSndrsbe a pack of the typesdecltype((sndrs))..., and let. The expressionsCDbe the typecommon_type_t<decltype(. Letget-domain-early(sndrs))...>CD2beCDifCDis well-formed, anddefault_domainotherwisewhen_all(sndrs...)andwhen_all_with_variant(sndrs...)are ill-formed if any of the following istrue:The expression
when_all(sndrs...)is expression-equivalent to:transform_sender(CD2(),make-sender(when_all, {}, sndrs...))The exposition-only class template impls-for ([exec.snd.expos]) is specialized for when_all_t as follows:
namespace std::execution { template<> structimpls-for<when_all_t> :default-impls{static constexpr autostatic constexpr autoget-attrs=see below;get-env=see below; static constexpr autoget-state=see below; static constexpr autostart=see below; static constexpr autocomplete=see below; template<class Sndr, class... Env> static consteval voidcheck-types(); }; }
[ Editor's note: Remove 33.9.12.12 [exec.when.all] paragraphs 10-11 as follows: ]
template<class Sndr, class... Env> static consteval voidcheck-types();
Let
Isbe the pack of integral template arguments of theinteger_sequencespecialization denoted by.indices-for<Sndr>Effects: Equivalent to: … as before …
Throws: Any exception thrown as a result of evaluating the Effects, or an exception of an unspecified type derived from
exceptionwhenCDis ill-formed.The member
is initialized with a callable object equivalent to the following lambda expression:impls-for<when_all_t>::get-attrs[](auto&&, auto&&... child) noexcept { if constexpr (same_as<CD, default_domain>) { return env<>() } else { returnMAKE-ENV(get_domain, CD()) } returnsee below; }
[ Editor's note: Change 33.9.12.12 [exec.when.all] paragraphs 20 and 21 as follows: ]
The expression
when_all_with_variant(sndrs...)is expression-equivalent to:transform_sender(CD2(),make-sender(when_all_with_variant, {}, sndrs...));Given subexpressions
sndrandenv, ifissender-for<decltype((sndr)), when_all_with_variant_t>false, then the expressionwhen_all_with_variant.transform_sender(is ill-formed; otherwise, it is equivalent to:set_value,sndr, env)auto&& [_, _, ...child] = sndr; return when_all(into_variant(std::forward_like<decltype((sndr))>(child))...);[ Note: This causes the
when_all_with_variant(sndrs...)sender to becomewhen_all(into_variant(sndrs)...)when it is connected with a receiver whose execution domain does not customizewhen_all_with_variant. — end note ]
[ Editor's note: Change 33.9.12.13 [exec.into.variant] paragraph 3 as follows: ]
Otherwise, the expression
into_variant(sndr)is expression-equivalent to:transform_sender(get-domain-early(sndr),make-sender(into_variant, {}, sndr));
[ Editor's note: Change 33.9.12.14 [exec.stopped.opt] paragrpah 2-4 as follows: ]
The name
stopped_as_optionaldenotes a pipeable sender adaptor object. For a subexpressionsndr, letSndrbedecltype((sndr)). The expressionstopped_as_optional(sndr)is expression-equivalent to:transform_sender(get-domain-early(sndr),make-sender(stopped_as_optional, {}, sndr))
except thatsndris only evaluated once.The exposition-only class template … as before …
Let
sndrandenvbe subexpressions such thatSndrisdecltype((sndr))andEnvisdecltype((env)). Ifissender-for<Sndr, stopped_as_error_t>false, then the expressionstopped_as_error.transform_sender(is ill-formed; otherwise, it is equivalent to: … as before …set_value,sndr, env)
[ Editor's note: Change 33.9.12.15 [exec.stopped.err] paragrpah 1-3 as follows: ]
stopped_as_errormaps an input sender’s stopped completion operation into an error completion operation as a custom error type. The result is a sender that never completes with stopped, reporting cancellation by completing with an error.The name
stopped_as_errordenotes a pipeable sender adaptor object. For some subexpressionssndranderr, letSndrbedecltype((sndr))and letErrbedecltype((err)). If the typeSndrdoes not satisfy sender or if the typeErrdoes not satisfymovable-value,stopped_as_error(sndr, err)is ill-formed. Otherwise, the expressionstopped_as_error(sndr, err)is expression-equivalent to:transform_sender(get-domain-early(sndr),make-sender(stopped_as_error, err, sndr))except that
sndris only evaluated once.Let
sndrandenvbe subexpressions such thatSndrisdecltype((sndr))andEnvisdecltype((env)). Ifissender-for<Sndr, stopped_as_error_t>false, then the expressionstopped_as_error.transform_sender(is ill-formed; otherwise, it is equivalent to: … as before …set_value,sndr, env)
[ Editor's note: Change 33.9.12.16 [exec.associate] paragraph 9 as follows: ]
The name
associatedenotes a pipeable sender adaptor object. For subexpressionssndrandtoken:
(9.1) If
decltype((sndr))does not satisfysender, orremove_cvref_t<decltype((token))>does not satisfyscope_token, thenassociate(sndr, token)is ill-formed.(9.2) Otherwise, the expression
associate(sndr, token)is expression-equivalent to:transform_sender(get-domain-early(sndr),make-sender(associate,associate-data(token, sndr)))
except thatsndris evaluated only once.
[ Editor's note: Change 33.9.13.1 [exec.sync.wait] paragraphs 4 as follows: ]
The name
this_thread::sync_waitdenotes a customization point object. For a subexpressionsndr, letSndrbedecltype((sndr)). The expressionthis_thread::sync_wait(sndr)is expression-equivalent to the following,except that:sndris evaluated only onceapply_sender(get-domain-early(sndr)Domain(), sync_wait, sndr)where
Domainis the type ofget_completion_domain<set_value_t>(get_env(sndr),.sync-wait-env{})Mandates:
[ Editor's note: Change 33.9.13.2 [exec.sync.wait.var] paragraph 1 as follows: ]
The name
this_thread::sync_wait_with_variantdenotes a customization point object. For a subexpressionsndr, letSndrbedecltype(into_variant(sndr)). The expressionthis_thread::sync_wait_with_variant(sndr)isexpression-equivalent to the following, exceptsndris evaluated only once:apply_sender(get-domain-early(sndr)Domain(), sync_wait_with_variant, sndr)where
Domainis the type ofget_completion_domain<set_value_t>(get_env(sndr),.sync-wait-env{})Mandates:
[ Editor's note: Change 33.11.1 [exec.prop] as follows: ]
namespace std::execution { template<class QueryTag, class ValueType> struct prop { QueryTag query_; // exposition only ValueType value_; // exposition only constexpr const ValueType& query(QueryTag, auto&&...) const noexcept { return value_; } }; template<class QueryTag, class ValueType> prop(QueryTag, ValueType) -> prop<QueryTag, unwrap_reference_t<ValueType>>; }… as before …
[ Editor's note: Change 33.11.2 [exec.env] as follows: ]
namespace std::execution { template<queryable... Envs> struct env { Envs0 envs0; // exposition only Envs1 envs1; // exposition only ⋮ Envsn-1 envsn-1; // exposition only template<class QueryTag, class... Args> constexpr decltype(auto) query(QueryTag q, Args&&... args) const noexcept(see below); }; template<class... Envs> env(Envs...) -> env<unwrap_reference_t<Envs>...>; }
- The class template
envis used to construct a queryable object from several queryable objects. Query invocations on the resulting object are resolved by attempting to query each subobject in lexical order.… as before …
template<class QueryTag, class... Args> constexpr decltype(auto) query(QueryTag q, Args&&... args) const noexcept(see below);
Let
has-querybe the following exposition-only concept:template<class Env, class QueryTag, class... Args> concepthas-query= // exposition only requires (const Env& env, Args&&... args) { env.query(QueryTag(), std::forward<Args>(args)...); };Let
febe the first element ofenvs0, envs1, … envsn-1such that the expressionis well-formed.fe.query(q, std::forward<Args>(args)...)Constraints:
(ishas-query<Envs, QueryTag, Args...> || ...)true.Effects: Equivalent to:
returnfe.query(q, std::forward<Args>(args)...);Remarks: The expression in the
noexceptclause is equivalent tonoexcept(.fe.query(q, std::forward<Args>(args)...))
[ Editor's note: In 33.12.1.2 [exec.run.loop.types], add a new paragraph after paragraph 4 as follows: ]
- Let
schbe an expression of typerun-loop-scheduler. The expressionschedule(sch)has typerun-loop-senderand is not potentially-throwing ifschis not potentially-throwing.
- For type
set-tagother thanset_error_t, the expressionget_completion_scheduler<evaluates toset-tag>(get_env(schedule(sch))) ==schtrue.
[ Editor's note: Change 33.13.3 [exec.affine.on] paragraphs 3 and 4 as follows: ]
Otherwise, the expression
affine_on(sndr, sch)is expression-equivalent to:.make-sender(affine_on, sch, sndr)transform_sender(get-domain-early(sndr),make-sender(affine_on, sch, sndr))except that
sndris evaluated only once.
The exposition-only class template
impls-for(33.9.2 [exec.snd.expos]) is specialized foraffine_on_tas follows:namespace std::execution { template<> structimpls-for<affine_on_t> :default-impls{ static constexpr autoget-attrs= [](const auto& data, const auto& child) noexcept -> decltype(auto) { returnJOIN-ENV(SCHED-ATTRS(data),FWD-ENV(get_env(child))); }; }; }
[ Editor's note: Change 33.13.4 [exec.inline.scheduler] paragraphs 1-3 as follows: ]
inline_scheduleris a class that modelsscheduler(33.6 [exec.sched]). All objects of typeinline_schedulerare equal. For a subexpressionschof typeinline_scheduler, a query objectq, and a pack of subexpressionsas, the expressionsch.query(q, as...)is expression-equivalent to.inline-attrs<set_value_t>().query(q, as...)
inline-senderis an exposition-only type that satisfiessender. The typecompletion_signatures_of_t<isinline-sender>completion_signatures<set_value_t()>.Let
sndrbe an expression of typeinline-sender, letrcvrbe an expression such thatreceiver_of<decltype((rcvr)), CS>istruewhereCSiscompletion_signatures<set_value_t()>, then:
- (3.1) the expression
connect(sndr, rcvr)has typeand is potentially-throwing if and only ifinline-state<remove_cvref_t<decltype((rcvr))>>((void)sndr, auto(rcvr))is potentially-throwing, and
- (3.2) the expression
get_completion_scheduler<set_value_t>(get_env(sndr))has typeinline_schedulerand is potentially-throwing if and only ifget_env(sndr)is potentially-throwing.[ Editor's note: For reference: cplusplus/sender-receiver#349 ]
transform_senderThe proposal requires some changes to how
transform_sender operates. This new
transform_sender still accepts a
sender and an environment like the current one, but it no longer accepts
a domain. It computes the two domains, starting and completing, and
applies the two transforms, recursing if a transform changes the type of
the sender.
The implementation of
transform_sender might look
something like this:
template<class A, class B> conceptsame-decayed= std::same_as<std::decay_t<A>, std::decay_t<B>>; template<class Domain, class Tag> structtransform-sender-recurse{ template<class Sndr, class Env> usingresult-t= decltype(Domain().transform_sender(Tag(), declval<Sndr>(), declval<const Env&>())); constexprtransform-sender-recurse(Domain, Tag) noexcept {} template<class Sndr, class Env> decltype(auto) operator()(this auto self, Sndr&& sndr, const Env& env) { if constexpr (!requires { typenameresult-t<Sndr, Env>; }) { // Domain does not have a transform_sender for this sndr so use default_domain instead. returntransform-sender-recurse<default_domain, Tag>()(forward<Sndr>(sndr), env); } else if constexpr (same-decayed<Sndr,result-t<Sndr, Env>>) { // Domain can transform the sender but its type does not change. End recursion. return Domain().transform_sender(Tag(), std::forward<Sndr>(sndr), env); } else if constexpr (same_as<Tag, start_t>) { // The starting domain cannot change, so recurse on Domain return self(Domain().transform_sender(start, std::forward<Sndr>(sndr), env), env); } else { // The type of sndr changed after being transformed, so the type of the completion // domain could change too. Recurse on the (possibly) new domain: using attrs_t = env_of_t<result-t<Sndr, Env>>; using domain_t = decltype(get_completion_domain<>(declval<attrs_t>(), env)); returntransform-sender-recurse<domain_t, Tag>()( Domain().transform_sender(set_value, std::forward<Sndr>(sndr), env), env); } } }; template<class Sndr, class Env> auto transform_sender(Sndr&& sndr, const Env& env) { auto starting_domain = get_domain(env); auto complete_domain = get_completion_domain<>(get_env(sndr), env); auto starting_transform =transform-sender-recurse(starting_domain, start); auto complete_transform =transform-sender-recurse(complete_domain, set_value); return starting_transform(complete_transform(std::forward<Sndr>(sndr), env), env); }
With this definition of
transform_sender, connect(sndr, rcvr)
is equivalent to transform_sender(sndr, get_env(rcvr)).connect(rcvr),
except that rcvr is evaluated only
once.