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 concept <code>unstoppable_token<Token></code> is modeled by a <code>_Token_</code> if <code>stoppable_token<_Token_></code> is true and it can statically be determined that both <code>_token_.stop_requested()</code> and <code>_token_.stop_possible()</code> are `constexpr` epxressions yielding `false`. This concept is primarily used to avoid extra work when using stop tokens which will never indicate that cancellations are requested.
339
+
The concept <code>unstoppable_token<Token></code> is modeled by a <code>_Token_</code> if <code>stoppable_token<_Token_></code> is true and it can statically be determined that both <code>_token_.stop_requested()</code> and <code>_token_.stop_possible()</code> are `constexpr` epxressions yielding `false`. This concept is used to avoid extra work when using stop tokens which will never indicate that cancellations are requested.
The queries are used to obtain properties associated with and object. Except <code><ahref=‘#forwarding-query’>forwarding_query</a></code> and <code><ahref=‘#get-env’>get_env</a></code> the queries work on <ahref=‘#environment’>environments</a>.
355
+
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.
357
+
<details>
358
+
<summary>Example defining a query on an environment</summary>
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.
376
+
<blockquote>
377
+
<details>
378
+
<summary>Example</summary>
379
+
When defining a custom query <code><i>custom</i></code> it is desirable to allow the query getting forwarded. It is necessary to explicit define the result of <code>forwarding_query(<i>custom</i>)</code>. The result can be defined by providing a corresponding `query` member function. When using this approach the function isn’t allowed to throw, needs to return `bool`, and needs to be a core constant expression:
<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.
The example defines an <ahref=‘#environment’>environment</a> class <code>env</code> which stores a pointer to the relevant data and is returned as the <ahref=‘#environment’>environment</a> for the type `queryable`:
<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.
This example shows how to define an environment class which provides a <a href=‘#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<>`.
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>.
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>.
458
+
<div>
459
+
<details>
460
+
<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:
0 commit comments