Files
cppdraft_translate/cppdraft/exec/factories.md
2025-10-25 03:02:53 +03:00

5.6 KiB
Raw Blame History

[exec.factories]

33 Execution control library [exec]

33.9 Senders [exec.snd]

33.9.11 Sender factories [exec.factories]

33.9.11.1 execution::schedule [exec.schedule]

1

#

schedule obtains a schedule sender ([exec.async.ops]) from a scheduler.

2

#

The name schedule denotes a customization point object.

For a subexpression sch, the expression schedule(sch) is expression-equivalent tosch.schedule().

3

#

Mandates: The type of sch.schedule() satisfies sender.

4

#

If the expressionget_completion_scheduler<set_value_t>(get_env(sch.schedule())) == sch is ill-formed or evaluates to false, the behavior of calling schedule(sch) is undefined.

33.9.11.2 execution::just, execution::just_error, execution::just_stopped [exec.just]

1

#

just, just_error, and just_stopped are sender factories whose asynchronous operations complete synchronously in their start operation with a value completion operation, an error completion operation, or a stopped completion operation, respectively.

2

#

The names just, just_error, and just_stopped denote customization point objects.

Let just-cpo be one ofjust, just_error, or just_stopped.

For a pack of subexpressions ts, let Ts be the pack of types decltype((ts)).

The expression just-cpo(ts...) is ill-formed if

(movable-value &&...) is false, or

just-cpo is just_error andsizeof...(ts) == 1 is false, or

just-cpo is just_stopped andsizeof...(ts) == 0 is false.

Otherwise, it is expression-equivalent tomake-sender(just-cpo, product-type{ts...}).

For just, just_error, and just_stopped, let set-cpo beset_value, set_error, and set_stopped, respectively.

The exposition-only class template impls-for ([exec.snd.expos]) is specialized for just-cpo as follows:namespace std::execution {template<>struct impls-for<decayed-typeof<just-cpo>> : default-impls {static constexpr auto start =[](auto& state, auto& rcvr) noexcept -> void {auto& [...ts] = state; set-cpo(std::move(rcvr), std::move(ts)...); }; };}

33.9.11.3 execution::read_env [exec.read.env]

1

#

read_env is a sender factory for a sender whose asynchronous operation completes synchronously in its start operation with a value completion result equal to a value read from the receiver's associated environment.

2

#

read_env is a customization point object.

For some query object q, the expression read_env(q) is expression-equivalent tomake-sender(read_env, q).

3

#

The exposition-only class template impls-for ([exec.snd.expos]) is specialized for read_env as follows:

🔗

namespace std::execution {template<>struct impls-for<decayed-typeof<read_env>> : default-impls {static constexpr auto start =[](auto query, auto& rcvr) noexcept -> void {TRY-SET-VALUE(rcvr, query(get_env(rcvr))); }; }; template<class Sndr, class Env>static consteval void check-types();}

🔗

template<class Sndr, class Env> static consteval void check-types();

4

#

Let Q be decay_t<data-type>.

5

#

Throws: An exception of an unspecified type derived from exception if the expression Q()(env) is ill-formed or has type void, whereenv is an lvalue subexpression whose type is Env.