33 Execution control library [exec] (original) (raw)
33.11 Queryable utilities [exec.envs]
33.11.1 Class template prop [exec.prop]
namespace std::execution { template<class QueryTag, class ValueType> struct prop { QueryTag query_; ValueType value_; constexpr const ValueType& query(QueryTag) const noexcept { return value_;} };template<class QueryTag, class ValueType> prop(QueryTag, ValueType) -> prop<QueryTag, unwrap_reference_t<ValueType>>;}
Class template prop is for building a queryable object from a query object and a value.
Mandates: callable<QueryTag, _prop-like_<ValueType>>is modeled, where prop-like is the following exposition-only class template:template<class ValueType> struct prop-like { const ValueType& query(auto) const noexcept;};
[Example 1: template<sender Sndr>sender auto parameterize_work(Sndr sndr) { auto e = prop(get_allocator, my_alloc{});return write_env(sndr, e);} — _end example_]
Specializations of prop are not assignable.
33.11.2 Class template env [exec.env]
namespace std::execution { template<queryable... Envs> struct env { Envs ; Envs ; ⋮ Envs ; template<class QueryTag> constexpr decltype(auto) query(QueryTag q) const noexcept(see below);};template<class... Envs> env(Envs...) -> env<unwrap_reference_t<Envs>...>;}
The class template env is 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.
Specializations of env are not assignable.
[Example 1: template<sender Sndr>sender auto parameterize_work(Sndr sndr) { auto e = env{prop(get_allocator, my_alloc{}), prop(get_scheduler, my_sched{})};return write_env(sndr, e);} — _end example_]
template<class QueryTag> constexpr decltype(auto) query(QueryTag q) const noexcept(_see below_);
Let has-query be the following exposition-only concept:template<class Env, class QueryTag> concept has-query = requires (const Env& env) { env.query(QueryTag());};
Let fe be the first element of, , …, such that the expression fe.query(q) is well-formed.
Constraints: (has-query<Envs, QueryTag> || ...) is true.
Effects: Equivalent to: return fe.query(q);
Remarks: The expression in the noexcept clause is equivalent to noexcept(fe.query(q)).