Skip to content

Commit

Permalink
Merge pull request #159 from cplusplus/port-read-to-basic-sender
Browse files Browse the repository at this point in the history
port the `read` sender factory to `basic-sender`
  • Loading branch information
ericniebler authored Dec 11, 2023
2 parents 4e64978 + 04f6296 commit 4efe7b2
Showing 1 changed file with 10 additions and 45 deletions.
55 changes: 10 additions & 45 deletions execution.bs
Original file line number Diff line number Diff line change
Expand Up @@ -5773,55 +5773,20 @@ template<class Domain, class Tag, sender Sender, class... Args>
completes synchronously in its start operation with a value completion
result equal to a value read from the receiver's associated environment.

2. `read` is a customization point object of the unspecified class type:
2. `read` is a customization point object. For some query object `q` of type `Q`,
the expression `read(q)` is expression-equivalent to
<code><i>make-sender</i>(read, q)</code>.

<pre highlight="c++">
template&lt;class Tag>
struct <i>read-sender</i>; // exposition only

struct <i>read-t</i> { // exposition only
template&lt;class Tag>
constexpr <i>read-sender</i>&lt;Tag> operator()(Tag) const noexcept {
return {};
}
};
</pre>

3. <code><i>read-sender</i></code> is the exposition-only class template:
3. The exposition-only class template <code><i>impls-for</i></code> ([exec.snd.general])
is specialized for `read` as follows:

<pre highlight="c++">
template&lt;class Tag>
struct <i>read-sender</i> { // exposition only
using sender_concept = sender_t;
template&lt;class R>
struct <i>operation-state</i> { // exposition only
R r_; // exposition only

friend void tag_invoke(start_t, <i>operation-state</i>& s) noexcept {
<i>TRY-SET-VALUE</i>(std::move(s.r_), Tag{}(get_env(s.r_)));
}
};

template&lt;receiver R>
friend <i>operation-state</i>&lt;decay_t&lt;R>> tag_invoke(connect_t, <i>read-sender</i>, R && r) {
return { std::forward&lt;R>(r) };
}

template&lt;class Env>
requires <i>callable</i>&lt;Tag, Env>
friend auto tag_invoke(get_completion_signatures_t, <i>read-sender</i>, Env)
-> completion_signatures&lt;
set_value_t(<i>call-result-t</i>&lt;Tag, Env>), set_error_t(exception_ptr)>; <i>// not defined</i>

template&lt;class Env>
requires <i>nothrow-callable</i>&lt;Tag, Env>
friend auto tag_invoke(get_completion_signatures_t, <i>read-sender</i>, Env)
-> completion_signatures&lt;set_value_t(<i>call-result-t</i>&lt;Tag, Env>)>; <i>// not defined</i>

friend empty_env tag_invoke(get_env_t, const <i>read-sender</i>&) noexcept {
return {};
}
template&lt;>
struct <i>impls-for</i>&lt;tag_t&lt;read>> : <i>default-impls</i> {
static constexpr auto start = [](auto query, auto& rcvr) noexcept -> void {
<i>TRY-SET-VALUE</i>(std::move(rcvr), query(get_env(rcvr)));
};
};
</pre>

### Sender adaptors <b>[exec.adapt]</b> ### {#spec-execution.senders.adapt}
Expand Down

0 comments on commit 4efe7b2

Please sign in to comment.