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

9.6 KiB

[exec.snd.concepts]

33 Execution control library [exec]

33.9 Senders [exec.snd]

33.9.3 Sender concepts [exec.snd.concepts]

1

#

The sender concept defines the requirements for a sender type ([exec.async.ops]).

The sender_in concept defines the requirements for a sender type that can create asynchronous operations given an associated environment type.

The sender_to concept defines the requirements for a sender type that can connect with a specific receiver type.

The get_env customization point object is used to access a sender's associated attributes.

The connect customization point object is used to connect ([exec.async.ops]) a sender and a receiver to produce an operation state.

🔗

namespace std::execution {templateconcept is-constant = true; // exposition onlytemplateconcept is-sender = // exposition onlyderived_from<typename Sndr::sender_concept, sender_t>; templateconcept enable-sender = // exposition onlyis-sender ||is-awaitable<Sndr, env-promise<env<>>>; // [exec.awaitable]templateinline constexpr bool enable_sender = enable-sender; templateconsteval bool is-dependent-sender-helper() try { // exposition only get_completion_signatures(); return false; } catch (dependent_sender_error&) {return true; }templateconcept sender = enable_sender<remove_cvref_t> &&requires (const remove_cvref_t& sndr) {{ get_env(sndr) } -> queryable; } &&move_constructible<remove_cvref_t> &&constructible_from<remove_cvref_t, Sndr>; template<class Sndr, class... Env>concept sender_in =sender &&(sizeof...(Env) <= 1) &&(queryable &&...) &&is-constant<get_completion_signatures<Sndr, Env...>()>; templateconcept dependent_sender =sender && bool_constant<is-dependent-sender-helper()>::value; template<class Sndr, class Rcvr>concept sender_to =sender_in<Sndr, env_of_t> &&receiver_of<Rcvr, completion_signatures_of_t<Sndr, env_of_t>> &&requires (Sndr&& sndr, Rcvr&& rcvr) { connect(std::forward(sndr), std::forward(rcvr)); };}

2

#

For a type Sndr, ifsender is true anddependent_sender is false, then Sndr is a non-dependent sender ([exec.async.ops]).

3

#

Given a subexpression sndr, let Sndr be decltype((sndr)) and let rcvr be a receiver with an associated environment whose type is Env.

A completion operation is a permissible completion for Sndr and Env if its completion signature appears in the argument list of the specialization of completion_signatures denoted bycompletion_signatures_of_t<Sndr, Env>.

Sndr and Env model sender_in<Sndr, Env> if all the completion operations that are potentially evaluated by connecting sndr to rcvr and starting the resulting operation state are permissible completions for Sndr and Env.

4

#

Remarks: Pursuant to [namespace.std], users may specialize enable_sender totrue for cv-unqualified program-defined types that model sender, andfalse for types that do not.

Such specializations shall be usable in constant expressions ([expr.const]) and have type const bool.

5

#

The exposition-only conceptssender-of and sender-in-of define the requirements for a sender type that completes with a given unique set of value result types.

namespace std::execution {template<class... As>using value-signature = set_value_t(As...); // exposition onlytemplate<class Sndr, class SetValue, class... Env>concept sender-in-of-impl = // exposition onlysender_in<Sndr, Env...> &&MATCHING-SIG(SetValue, // see [exec.general]gather-signatures<set_value_t, // see [exec.cmplsig] completion_signatures_of_t<Sndr, Env...>, value-signature, type_identity_t>); template<class Sndr, class Env, class... Values>concept sender-in-of = // exposition onlysender-in-of-impl<Sndr, set_value_t(Values...), Env>; template<class Sndr, class... Values>concept sender-of = // exposition onlysender-in-of-impl<Sndr, set_value_t(Values...)>;}

6

#

Let sndr be an expression such that decltype((sndr)) is Sndr.

The type tag_of_t is as follows:

If the declarationauto&& [tag, data, ...children] = sndr; would be well-formed, tag_of_t is an alias for decltype(auto(tag)).

Otherwise, tag_of_t is ill-formed.

7

#

Let sender-for be an exposition-only concept defined as follows:namespace std::execution {template<class Sndr, class Tag>concept sender-for =sender &&same_as<tag_of_t, Tag>;}

8

#

For a type T,SET-VALUE-SIG(T) denotes the type set_value_t() if T is cv void; otherwise, it denotes the type set_value_t(T).

9

#

Library-provided sender types

always expose an overload of a member connect that accepts an rvalue sender and

only expose an overload of a member connect that accepts an lvalue sender if they model copy_constructible.