You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The queries are used to obtain properties associated with an object. Except <code><ahref=‘#forwarding-query’>forwarding_query</a></code>, <code><ahref=‘#get-env’>get_env</a></code>, and <code><ahref=‘#get-completion-signatures’>get_completion_signatures</a></code> the queries work on <ahref=‘#environment’>environments</a>. The
356
-
<ahref=‘#environment’>environment</a> queries are defined by providing a member <code>query(<i>query_t</i>, <i>a...</i>) const</code> on the <ahref=‘#environment’>environment</a> object.
355
+
The queries are used to obtain properties associated with an object.
356
+
357
357
<details>
358
358
<summary>Example defining a query on an environment</summary>
359
359
This example shows how to define an environment class which provides a <ahref=‘#get-allocator’><code>get_allocator</code></a> query. The objects stores a `std::pmr::memory_resource*` and returns a correspondingly initialized `std::pmr::polymorphic_allocator<>`.
<code>forwarding_query(<i>query</i>)</code> is a `constexpr` query used to determine if the query <code><i>query</i></code> should be forwarded when wrapping an environment.
375
+
The expression <code>forwarding_query(<i>query</i>)</code> is a `constexpr` query used to determine if the query <code><i>query</i></code> should be forwarded when wrapping an environment. The expression is required to be a core constant expression if <code><i>query</i></code> is a core constant expression.
376
+
377
+
The result of the expression is determined as follows:
378
+
<ol>
379
+
<li>The result is the value of the expression <code><i>query</i>.query(forwarding_query)</code> if this expression is valid and `noexcept`.</li>
380
+
<li>The result is <code>true</code> if the type of <code><i>query</i></code> is <code>public</code>ly derived from <code>forwarding_query</code>.</li>
<code>get_env(<i>queryable</i>)</code> is used to get the environment <code><i>env</i></code> associated with <code><i>queryable</i></code>. To provide a non-default environment for a <code><i>queryable</i></code> a `get_env` member needs to be defined. If <code><i>queryable</i></code> doesn’t provide the <code>get_env</code> query an object of type <code><ahref=‘#empty_env’>empty_env</a></code> is returned.
412
+
The expresion <code>get_env(<i>queryable</i>)</code> is used to get the environment <code><i>env</i></code> associated with <code><i>queryable</i></code>. To provide a non-default environment for a <code><i>queryable</i></code> a `get_env` member needs to be defined. If <code><i>queryable</i></code> doesn’t provide the <code>get_env</code> query an object of type <code><ahref=‘#empty_env’>empty_env</a></code> is returned.
413
+
The value of the expression is <ol>
414
+
<li>the result of <code>as_const(<i>queryable</i>).get_env()</code> if this expression is valid and <code>noexcept</code>.</li>
415
+
<li><code>empty_env</code> otherwise.
416
+
</ol>
406
417
<div>
407
418
<details>
408
419
<summary>Example</summary>
@@ -428,7 +439,14 @@ Note that the `get_env` member is both `const` and `noexcept`.
<code>get_allocator(<i>env</i>)</code> returns an <code><i>allocator</i></code> for any memory allocations in the respective context. If <code><i>env</i></code> doesn’t support this query any attempt to access it will result in a compilation error.
442
+
The expression <code>get_allocator(<i>env</i>)</code> returns an <code><i>allocator</i></code> for any memory allocations in the respective context. If <code><i>env</i></code> doesn’t support this query any attempt to access it will result in a compilation error. The value of the expression <code>get_allocator(<i>env</i>)</code> is the result of <code>as_const(<i>env</i>).query(get_allocator)</code> if
443
+
<ul>
444
+
<li>the expression is valid</code>;</li>
445
+
<li>the expression is <code>noexcept</code>;</li>
446
+
<li>the result of the expression satisfies <code><i>simple-allocator</i></code>.</li>
If the expression <code>get_completion_scheduler<tag>(get_env(<i>sender</i>))</code> is well-formed and returns a scheduler it defines the scheduler on which the completion <code><i>tag</i></code> executes. In particular <code>get_completion_scheduler<set_value_t>(schedule(<i>sched</i>))</code> returns <code><i>sched</i></code>.
471
+
The expression <code>get_complet_scheduler<Tag>(<i>env</i>)</code> yields the completion scheduler for the completion signal <code>Tag</code> associated with <code><i>env</i></code>. This query can be used to determine the scheduler a sender <code><i>sender</i></code> completes on for a given completion signal <code>Tag</code> by using <code>get_completion_scheduler<Tag>(get_env(<i>sender</i>))</code>. The value of the expression is equivalent to <code>as_const(<i>env</i>).query(get_completion_scheduler<Tag>)</code> if
472
+
<ol>
473
+
<li><code>Tag</code> is one of the types <code>set_value_t</code>, <code>set_error_t</code>, or <code>set_stopped_t</code>;
474
+
<li>this expression is valid;</li>
475
+
<li>this expression is <code>noexcept</code>;</li>
476
+
<li>the expression’s type satisfies <code>scheduler</code>.
The expression <code>get_completion_signatures(<i>sender</i>, <i>env</i>)</code> returns an object whose type is a specialization of <a href=‘#completion-signatures’><code>completion_signatures</code></a> defining the possible completion signatures of <code><i>sender</i></code> when connected to a <a href=‘#receiver’><code><i>receiver</i></code></a> whose <a href=‘#environment'>environment</a> <code>get_env(<i>receiver</i>)</code> is <code><i>env</i></code>. A <a href=‘#sender’><code>sender</code></a> can define the result of this query either by defining a member function <code>get_completion_signatures</code> or using a type alias <code>completion_signatures</code>.
483
+
484
+
To determine the result the <code><i>sender</i></code> is first transformed using <code>transform_sender(<i>domain</i>, <i>sender</i>, <i>env</i>)</code> to get <code><i>new-sender</i></code> with type <code><i>New-Sender-Type</i></code>. With that the result type is
485
+
<ol>
486
+
<li>the type of <code><i>new-sender</i>.get_completion_signatures(<i>env</i>)</code> if this expression is valid;</li>
487
+
<li>the type <code>remove_cvref_t<<i>New-Sender-Type</i>>::completion_signatures</code> if this type exists;</li>
488
+
<li><code>completion_signatures<set_value_t(<i>T</i>), set_error_t(exception_ptr), set_stopped_t()></code> if <code><i>New-Sender-Type</i></code> is an awaitable type which would yield an object of type <code><i>T</i></code> when it is <code>co_await</code>ed;</li>
489
+
<li>invalid otherwise.</code>
490
+
</ol>
458
491
<div>
459
492
<details>
460
493
<summary>Example</summary>
461
-
When a <a href=‘#sender’><code>sender</code></a> doesn’t need to compute the completion signatures based on an <a href=‘#environment’>environment</a> it is easiest to use a the type alias:
462
-
463
-
494
+
When a <a href=‘#sender’><code>sender</code></a> doesn’t need to compute the completion signatures based on an <a href=‘#environment’>environment</a> it is easiest to use a the type alias, e.g.:
495
+
```c++
496
+
struct sender {
497
+
using sender_concept = std::execution::sender_t;
498
+
using completion_signatures = std::completion_signatures<
The expression <code>get_delegation_scheduler(<i>env</i>)</code> yields the scheduler associated with <code><i>env</i></code> which is used for forward progress delegation. The value of the expression is equivalent to <code>as_const(<i>env</i>).query(get_delegation_scheduler) -> <i>scheduler</i></code> if
512
+
<ol>
513
+
<li>this expression is valid;</li>
514
+
<li>this expression is <code>noexcept</code>;</li>
515
+
<li>the expression’s type satisfies <code>scheduler</code>.
The expression <code>get_domain(<i>env</i>)</code> yields the domain associated with <code><i>env</i></code>. The value of the expression is equivalent to <code>as_const(<i>env</i>).query(get_domain)</code> if
523
+
<ol>
524
+
<li>this expression is valid;</li>
525
+
<li>this expression is <code>noexcept</code>.</li>
The expression <code>get_forward_progress_guarantee(<i>scheduler</i>)</code> yields the forward progress guarantee of the <i>scheduler</i>’s execution agent. The value of the expression is equivalent to <code>as_const(<i>env</i>).query(get_scheduler)</code> if
532
+
<ol>
533
+
<li>this expression is valid;</li>
534
+
<li>this expression is <code>noexcept</code>;</li>
535
+
<li>the expression’s type is <code>forward_progress_guarantee</code>.
The expression <code>get_scheduler(<i>env</i>)</code> yields the scheduler associated with <code><i>env</i></code>. The value of the expression is equivalent to <code>as_const(<i>env</i>).query(get_scheduler)</code> if
542
+
<ol>
543
+
<li>this expression is valid;</li>
544
+
<li>this expression is <code>noexcept</code>;</li>
545
+
<li>the expression’s type satisfies <code>scheduler</code>.
The expression <code>get_stop_token(<i>env</i>)</code> yields the stop token associated with <code><i>env</i></code>. The value is the result of the expression <code>as_const(<i>env</i>).query(get_stop_token)</code> if
The expression <code>set_error(<i>receiver</i>, <i>error</i>)</code> invokes the <code>set_error</code> completion signal on <code><i>receiver</i></code> with the argument <code><i>error</i></code>, i.e., it invokes <code><i>receiver</i>.set_error(<i>error</i>)</code>.
The expression <code>set_stopped(<i>receiver</i>)</code> invokes the <code>set_stopped</code> completion signal on <code><i>receiver</i></code>, i.e., it invokes <code><i>receiver</i>.set_stopped()</code>.
The expression <code>set_value(<i>receiver</i>, <i>value</i>...)</code> invokes the <code>set_value</code> completion signal on <code><i>receiver</i></code> with the argument(s) <code><i>value</i>...</code>, i.e., it invokes <code><i>receiver</i>.set_value(<i>value</i>...)</code>.
The expression <code>start(<i>state</i>)</code> starts the execution of the <code>operation_state</code> object <code><i>state</i></code>. Once this expression started executing the object <code><i>state</i></code> is required to stay valid at least until one of the completion signals of <code><i>state</i></code>’s <code>receiver</code> is invoked. Once started exactly one of the completion signals is eventually called.
0 commit comments