3.2 KiB
[exec.write.env]
33 Execution control library [exec]
33.9 Senders [exec.snd]
33.9.12 Sender adaptors [exec.adapt]
33.9.12.3 execution::write_env [exec.write.env]
write_env is a sender adaptor that accepts a sender and a queryable object, and that returns a sender that, when connected with a receiver rcvr, connects the adapted sender with a receiver whose execution environment is the result of joining the queryable object to the result of get_env(rcvr).
write_env is a customization point object.
For some subexpressions sndr and env, if decltype((sndr)) does not satisfy sender or if decltype((env)) does not satisfy queryable, the expression write_env(sndr, env) is ill-formed.
Otherwise, it is expression-equivalent tomake-sender(write_env, env, sndr).
Let write-env-t denote the type decltype(auto(write_env)).
The exposition-only class template impls-for ([exec.snd.expos]) is specialized for write-env-t as follows:
template<>struct impls-for<write-env-t> : default-impls {static constexpr auto join-env(const auto& state, const auto& env) noexcept {return see below; }static constexpr auto get-env =[](auto, const auto& state, const auto& rcvr) noexcept {return join-env(state, FWD-ENV(get_env(rcvr))); }; template<class Sndr, class... Env>static consteval void check-types();};
Invocation ofimpls-for<write-env-t>::join-env returns an object e such that
decltype(e) models queryable and
given a query object q, the expression e.query(q) is expression-equivalent to state.query(q) if that expression is valid, otherwise, e.query(q) is expression-equivalent to env.query(q).
For a type Sndr and a pack of types Env, let State be data-type and let JoinEnv be the packdecltype(join-env(declval(), FWD-ENV(declval()))).
Then impls-for<write-env-t>::check-types<Sndr, Env...>() is expression-equivalent toget_completion_signatures<child-
type, JoinEnv...>().