3.1 KiB
[exec.into.variant]
33 Execution control library [exec]
33.9 Senders [exec.snd]
33.9.12 Sender adaptors [exec.adapt]
33.9.12.13 execution::into_variant [exec.into.variant]
into_variant adapts a sender with multiple value completion signatures into a sender with just one value completion signature consisting of a variant of tuples.
The name into_variant denotes a pipeable sender adaptor object.
For a subexpression sndr, let Sndr be decltype((sndr)).
If Sndr does not satisfy sender,into_variant(sndr) is ill-formed.
Otherwise, the expression into_variant(sndr) is expression-equivalent to:transform_sender(get-domain-early(sndr), make-sender(into_variant, {}, sndr)) except that sndr is only evaluated once.
The exposition-only class template impls-for ([exec.snd.expos]) is specialized for into_variant as follows:
namespace std::execution {template<>struct impls-for<into_variant_t> : default-impls {static constexpr auto get-state = see below; static constexpr auto complete = see below; template<class Sndr, class... Env>static consteval void check-types() {auto cs = get_completion_signatures<child-type, FWD-ENV-T(Env)...>(); decay-copyable-result-datums(cs); // see [exec.snd.expos]}};}
The member impls-for<into_variant_t>::get-state is initialized with a callable object equivalent to the following lambda:[]<class Sndr, class Rcvr>(Sndr&& sndr, Rcvr& rcvr) noexcept-> type_identity<value_types_of_t<child-type, FWD-ENV-T(env_of_t)>> {return {};}
The member impls-for<into_variant_t>::complete is initialized with a callable object equivalent to the following lambda:[]<class State, class Rcvr, class Tag, class... Args>(auto, State, Rcvr& rcvr, Tag, Args&&... args) noexcept -> void {if constexpr (same_as<Tag, set_value_t>) {using variant_type = typename State::type; TRY-SET-VALUE(rcvr, variant_type(decayed-tuple<Args...>{std::forward(args)...})); } else { Tag()(std::move(rcvr), std::forward(args)...); }}