[exec.envs] # 33 Execution control library [[exec]](./#exec) ## 33.11 Queryable utilities [exec.envs] ### [33.11.1](#exec.prop) Class template prop [[exec.prop]](exec.prop) namespace std::execution {templatestruct [prop](#lib:prop "33.11.1 Class template prop [exec.prop]") { QueryTag *query_*; // *exposition only* ValueType *value_*; // *exposition only*constexpr const ValueType& query(QueryTag) const noexcept {return *value_*; }}; template prop(QueryTag, ValueType) -> prop>;} [1](#exec.prop-1) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/exec.tex#L6193) Class template prop is for building a queryable object from a query object and a value[.](#exec.prop-1.sentence-1) [2](#exec.prop-2) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/exec.tex#L6197) *Mandates*: [*callable*](functional.syn#concept:callable "22.10.2 Header synopsis [functional.syn]")> is modeled, where *prop-like* is the following exposition-only class template:templatestruct *prop-like* { // *exposition only*const ValueType& query(auto) const noexcept;}; [3](#exec.prop-3) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/exec.tex#L6209) [*Example [1](#exec.prop-example-1)*: template<[sender](exec.snd.concepts#concept:sender "33.9.3 Sender concepts [exec.snd.concepts]") Sndr> sender auto parameterize_work(Sndr sndr) {// Make an environment such that get_allocator(env) returns a reference to a copy of my_alloc{}.auto e = prop(get_allocator, my_alloc{}); // Parameterize the input sender so that it will use our custom execution environment.return write_env(sndr, e);} — *end example*] [4](#exec.prop-4) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/exec.tex#L6223) Specializations of prop are not assignable[.](#exec.prop-4.sentence-1) ### [33.11.2](#exec.env) Class template env [[exec.env]](exec.env) namespace std::execution {template<[*queryable*](exec.queryable.concept#concept:queryable "33.2.2 queryable concept [exec.queryable.concept]")... Envs>struct [env](#lib:env "33.11.2 Class template env [exec.env]") { Envs0 envs0; // *exposition only* Envs1 envs1; // *exposition only* ⋮ Envsn−1 envsn−1; // *exposition only*templateconstexpr decltype(auto) query(QueryTag q) const noexcept(*see below*); }; template env(Envs...) -> env...>;} [1](#exec.env-1) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/exec.tex#L6246) The class template env is used to construct a queryable object from several queryable objects[.](#exec.env-1.sentence-1) Query invocations on the resulting object are resolved by attempting to query each subobject in lexical order[.](#exec.env-1.sentence-2) [2](#exec.env-2) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/exec.tex#L6252) Specializations of env are not assignable[.](#exec.env-2.sentence-1) [3](#exec.env-3) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/exec.tex#L6255) It is unspecified whether env supports initialization using a parenthesized [*expression-list*](expr.post.general#nt:expression-list "7.6.1.1 General [expr.post.general]") ([[dcl.init]](dcl.init "9.5 Initializers")), unless the [*expression-list*](expr.post.general#nt:expression-list "7.6.1.1 General [expr.post.general]") consist of a single element of type (possibly const) env[.](#exec.env-3.sentence-1) [4](#exec.env-4) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/exec.tex#L6262) [*Example [1](#exec.env-example-1)*: template<[sender](exec.snd.concepts#concept:sender "33.9.3 Sender concepts [exec.snd.concepts]") Sndr> sender auto parameterize_work(Sndr sndr) {// Make an environment such that:// get_allocator(env) returns a reference to a copy of my_alloc{}// get_scheduler(env) returns a reference to a copy of my_sched{}auto e = env{prop(get_allocator, my_alloc{}), prop(get_scheduler, my_sched{})}; // Parameterize the input sender so that it will use our custom execution environment.return write_env(sndr, e);} — *end example*] [🔗](#lib:query,env) `template constexpr decltype(auto) query(QueryTag q) const noexcept(see below); ` [5](#exec.env-5) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/exec.tex#L6286) Let [*has-query*](#concept:has-query "33.11.2 Class template env [exec.env]") be the following exposition-only concept:templateconcept [*has-query*](#concept:has-query "33.11.2 Class template env [exec.env]") = // *exposition only*requires (const Env& env) { env.query(QueryTag()); }; [6](#exec.env-6) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/exec.tex#L6296) Let *fe* be the first element ofenvs0, envs1, …, envsn−1 such that the expression *fe*.query(q) is well-formed[.](#exec.env-6.sentence-1) [7](#exec.env-7) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/exec.tex#L6301) *Constraints*: ([*has-query*](#concept:has-query "33.11.2 Class template env [exec.env]") || ...) is true[.](#exec.env-7.sentence-1) [8](#exec.env-8) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/exec.tex#L6305) *Effects*: Equivalent to: return *fe*.query(q); [9](#exec.env-9) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/exec.tex#L6309) *Remarks*: The expression in the noexcept clause is equivalent to noexcept(*fe*.query(q))[.](#exec.env-9.sentence-1)