5
5
6
6
#include < beman/execution/detail/completion_signatures_of_t.hpp>
7
7
#include < beman/execution/detail/connect.hpp>
8
+ #include < beman/execution/detail/forwarding_query.hpp>
9
+ #include < beman/execution/detail/read_env.hpp>
8
10
#include < beman/execution/detail/just.hpp>
9
11
#include < beman/execution/detail/sender.hpp>
10
12
#include < beman/execution/detail/sender_in.hpp>
@@ -22,12 +24,21 @@ struct error {
22
24
};
23
25
struct non_sender {};
24
26
27
+ struct get_value_t : test_std::forwarding_query_t {
28
+ auto operator ()(const auto & e) const noexcept -> int { return e.query (*this ); }
29
+ };
30
+
25
31
struct receiver {
26
32
using receiver_concept = test_std::receiver_t ;
27
33
28
34
auto set_error (auto &&) && noexcept -> void {}
29
35
auto set_stopped () && noexcept -> void {}
30
36
auto set_value (auto &&...) && noexcept -> void {}
37
+
38
+ struct env {
39
+ auto query (const get_value_t &) const noexcept { return 42 ; }
40
+ };
41
+ auto get_env () const noexcept { return env{}; }
31
42
};
32
43
33
44
template <typename ... T>
@@ -214,6 +225,28 @@ auto test_then_allocator() -> void {
214
225
auto state{test_std::connect (std::move (sender), memory_receiver{&resource2})};
215
226
ASSERT (resource2.count == 1u );
216
227
}
228
+
229
+ auto test_then_env () -> void {
230
+ {
231
+ receiver r{};
232
+ auto e{test_std::get_env (r)};
233
+ ASSERT (e.query (get_value_t {}) == 42 );
234
+ ASSERT (get_value_t {}(e) == 42 );
235
+ }
236
+ {
237
+ auto state{test_std::connect (test_std::read_env (get_value_t {}), receiver{})};
238
+ test_std::start (state);
239
+ }
240
+ {
241
+ int value{0 };
242
+ auto state{test_std::connect (test_std::then (test_std::read_env (get_value_t {}), [&value](int v) { value = v; }),
243
+ receiver{})};
244
+ ASSERT (value == 0 );
245
+ test_std::start (state);
246
+ ASSERT (value == 42 );
247
+ }
248
+ }
249
+
217
250
} // namespace
218
251
219
252
TEST (exec_then) {
@@ -230,4 +263,6 @@ TEST(exec_then) {
230
263
test_then_multi_type ();
231
264
test_then_value ();
232
265
test_then_allocator ();
266
+
267
+ test_then_env ();
233
268
}
0 commit comments