File tree Expand file tree Collapse file tree 4 files changed +38
-16
lines changed
Expand file tree Collapse file tree 4 files changed +38
-16
lines changed Original file line number Diff line number Diff line change @@ -1193,7 +1193,7 @@ namespace exec {
11931193 CvrefSender,
11941194 env_of_t <Receiver>,
11951195 __q<__decayed_std_tuple>,
1196- __q<__std_variant >>;
1196+ __q<__nullable_std_variant >>;
11971197
11981198 variant_t data_;
11991199 static_thread_pool_& pool_;
@@ -1217,7 +1217,13 @@ namespace exec {
12171217 template <class F >
12181218 void apply (F f) {
12191219 std::visit (
1220- [&](auto & tupl) -> void { std::apply ([&](auto &... args) -> void { f (args...); }, tupl); },
1220+ [&](auto & tupl) -> void {
1221+ if constexpr (same_as<__decay_t <decltype (tupl)>, std::monostate>) {
1222+ std::terminate ();
1223+ } else {
1224+ std::apply ([&](auto &... args) -> void { f (args...); }, tupl);
1225+ }
1226+ },
12211227 data_);
12221228 }
12231229
Original file line number Diff line number Diff line change 1919#include < stdexec/execution.hpp>
2020#include < test_common/schedulers.hpp>
2121#include < test_common/receivers.hpp>
22+ #include < test_common/senders.hpp>
2223#include < test_common/type_helpers.hpp>
2324#include < exec/static_thread_pool.hpp>
2425
@@ -337,4 +338,18 @@ namespace {
337338 CHECK (actual != wrong);
338339 }
339340 }
341+
342+ TEST_CASE (" default bulk works with non-default constructible types" , " [adaptors][bulk]" ) {
343+ ex::sender auto s = ex::just (non_default_constructible{42 }) | ex::bulk (1 , [](int , auto &) {});
344+ ex::sync_wait (std::move (s));
345+ }
346+
347+ TEST_CASE (" static thread pool works with non-default constructible types" , " [adaptors][bulk]" ) {
348+ exec::static_thread_pool pool{4 };
349+ ex::scheduler auto sch = pool.get_scheduler ();
350+
351+ ex::sender auto s = ex::just (non_default_constructible{42 }) | ex::continues_on (sch)
352+ | ex::bulk (1 , [](int , auto &) {});
353+ ex::sync_wait (std::move (s));
354+ }
340355} // namespace
Original file line number Diff line number Diff line change 1818#include < stdexec/execution.hpp>
1919#include < test_common/schedulers.hpp>
2020#include < test_common/receivers.hpp>
21+ #include < test_common/senders.hpp>
2122#include < test_common/type_helpers.hpp>
2223#include < exec/any_sender_of.hpp>
2324#include < exec/static_thread_pool.hpp>
@@ -112,19 +113,6 @@ namespace {
112113 REQUIRE (called);
113114 }
114115
115- struct non_default_constructible {
116- int x;
117-
118- non_default_constructible (int x)
119- : x(x) {
120- }
121-
122- friend bool
123- operator ==(non_default_constructible const & lhs, non_default_constructible const & rhs) {
124- return lhs.x == rhs.x ;
125- }
126- };
127-
128116 TEST_CASE (
129117 " schedule_from can accept non-default constructible types" ,
130118 " [adaptors][schedule_from]" ) {
@@ -249,4 +237,4 @@ namespace {
249237 auto op = ex::connect (std::move (snd), expect_value_receiver (3 ));
250238 ex::start (op);
251239 }
252- } // namespace
240+ } // namespace
Original file line number Diff line number Diff line change @@ -168,4 +168,17 @@ namespace {
168168 return {self.condition_ , std::forward<Receiver>(rcvr)};
169169 }
170170 };
171+
172+ struct non_default_constructible {
173+ int x;
174+
175+ non_default_constructible (int x)
176+ : x(x) {
177+ }
178+
179+ friend bool
180+ operator ==(non_default_constructible const & lhs, non_default_constructible const & rhs) {
181+ return lhs.x == rhs.x ;
182+ }
183+ };
171184} // namespace
You can’t perform that action at this time.
0 commit comments