|
10 | 10 |
|
11 | 11 | namespace { |
12 | 12 | struct receiver { |
13 | | - int value{}; |
| 13 | + int& value; |
14 | 14 | auto set_value(int value) && noexcept -> void { this->value = value; } |
15 | 15 | }; |
16 | 16 |
|
17 | | -struct non_opstate {}; |
| 17 | +struct non_opstate { |
| 18 | + receiver rcvr; |
| 19 | +}; |
18 | 20 |
|
19 | 21 | template <bool Noexcept> |
20 | 22 | struct opstate { |
21 | | - receiver* rcvr; |
22 | | - auto start() const noexcept(Noexcept) -> void { test_std::set_value(::std::move(*rcvr), 42); } |
| 23 | + receiver rcvr; |
| 24 | + auto start() const noexcept(Noexcept) -> void { test_std::set_value(receiver(this->rcvr.value), 42); } |
23 | 25 | }; |
24 | 26 |
|
25 | 27 | template <typename State> |
26 | 28 | auto test_start_argument_type() { |
27 | | - receiver rcvr{}; |
28 | | - State state{&rcvr}; |
29 | | - receiver crcvr{}; |
30 | | - const State cstate{&crcvr}; |
| 29 | + int value{}; |
| 30 | + State state{receiver{value}}; |
| 31 | + int cvalue{}; |
| 32 | + const State cstate{receiver{cvalue}}; |
31 | 33 |
|
32 | 34 | static_assert(requires { test_std::start(state); }); |
33 | 35 | static_assert(requires { test_std::start(cstate); }); |
34 | 36 |
|
35 | | - static_assert(not requires { test_std::start(State(&rcvr)); }); |
| 37 | + static_assert(not requires { test_std::start(State(receiver{value})); }); |
36 | 38 | static_assert(not requires { test_std::start(std::move(state)); }); |
37 | 39 | static_assert(not requires { test_std::start(std::move(cstate)); }); |
38 | 40 | } |
39 | 41 |
|
40 | 42 | template <typename State> |
41 | 43 | auto test_start_member() { |
42 | | - State state{}; |
| 44 | + int value{}; |
| 45 | + State state{receiver{value}}; |
43 | 46 | static_assert(not requires { test_std::start(state); }); |
44 | | - State cstate{}; |
| 47 | + const State cstate{receiver{value}}; |
45 | 48 | static_assert(not requires { test_std::start(cstate); }); |
46 | 49 | } |
47 | 50 |
|
48 | 51 | template <typename State> |
49 | 52 | auto test_start_noexcept() { |
50 | | - State state{}; |
| 53 | + int value{}; |
| 54 | + State state{receiver{value}}; |
51 | 55 | static_assert(noexcept(state)); |
52 | | - State cstate{}; |
| 56 | + int cvalue{}; |
| 57 | + const State cstate{receiver{cvalue}}; |
53 | 58 | static_assert(noexcept(cstate)); |
54 | 59 | } |
55 | 60 |
|
56 | 61 | template <typename State> |
57 | 62 | auto test_start_call() { |
58 | | - receiver rcvr{}; |
59 | | - State state{&rcvr}; |
60 | | - receiver crcvr{}; |
61 | | - const State cstate{&crcvr}; |
| 63 | + int value{}; |
| 64 | + State state{receiver{value}}; |
| 65 | + int cvalue{}; |
| 66 | + const State cstate{receiver{cvalue}}; |
62 | 67 |
|
63 | | - ASSERT(rcvr.value == 0); |
| 68 | + ASSERT(value == 0); |
64 | 69 | test_std::start(state); |
65 | | - ASSERT(rcvr.value == 42); |
| 70 | + ASSERT(value == 42); |
66 | 71 |
|
67 | | - ASSERT(crcvr.value == 0); |
| 72 | + ASSERT(cvalue == 0); |
68 | 73 | test_std::start(cstate); |
69 | | - ASSERT(crcvr.value == 42); |
| 74 | + ASSERT(cvalue == 42); |
70 | 75 | } |
71 | 76 | } // namespace |
72 | 77 |
|
|
0 commit comments