Skip to content

Commit 8eb8b9a

Browse files
committed
foreach errors
1 parent 092d4ba commit 8eb8b9a

5 files changed

Lines changed: 46 additions & 46 deletions

File tree

libs/core/algorithms/include/hpx/parallel/container_algorithms/for_each.hpp

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -545,7 +545,8 @@ namespace hpx::ranges {
545545

546546
#if defined(HPX_HAVE_STDEXEC)
547547
// Sender algorithm support for stdexec integration
548-
template <typename Sender, typename ExPolicy, typename F, typename Proj = hpx::identity>
548+
template <typename Sender, typename ExPolicy, typename F,
549+
typename Proj = hpx::identity>
549550
// clang-format off
550551
requires (
551552
hpx::execution::experimental::sender<Sender> &&
@@ -557,31 +558,32 @@ namespace hpx::ranges {
557558
Sender&& sender, ExPolicy&& policy, F&& f, Proj&& proj = Proj{})
558559
{
559560
return HPX_FORWARD(Sender, sender) |
560-
hpx::execution::experimental::let_value([
561-
policy = HPX_FORWARD(ExPolicy, policy),
562-
f = HPX_FORWARD(F, f),
563-
proj = HPX_FORWARD(Proj, proj)
564-
](auto&& rng) mutable {
565-
return hpx::execution::experimental::just(
566-
hpx::for_each(policy, HPX_FORWARD(decltype(rng), rng),
567-
HPX_MOVE(f), HPX_MOVE(proj)));
568-
});
561+
hpx::execution::experimental::let_value(
562+
[policy = HPX_FORWARD(ExPolicy, policy),
563+
f = HPX_FORWARD(F, f),
564+
proj = HPX_FORWARD(Proj, proj)](auto&& rng) mutable {
565+
return hpx::execution::experimental::just(hpx::for_each(
566+
policy, HPX_FORWARD(decltype(rng), rng),
567+
HPX_MOVE(f), HPX_MOVE(proj)));
568+
});
569569
}
570570

571571
// Partial algorithm support for stdexec senders
572572
template <typename ExPolicy>
573-
friend auto tag_fallback_invoke(hpx::ranges::for_each_t,
574-
ExPolicy&& policy)
573+
friend auto tag_fallback_invoke(
574+
hpx::ranges::for_each_t, ExPolicy&& policy)
575575
{
576-
return [policy = HPX_FORWARD(ExPolicy, policy)](auto&& sender) mutable {
576+
return [policy = HPX_FORWARD(ExPolicy, policy)](
577+
auto&& sender) mutable {
577578
return HPX_FORWARD(decltype(sender), sender) |
578-
hpx::execution::experimental::let_value([
579-
policy = HPX_MOVE(policy)
580-
](auto&& rng, auto&& f) mutable {
581-
return hpx::execution::experimental::just(
582-
hpx::for_each(policy, HPX_FORWARD(decltype(rng), rng),
583-
HPX_FORWARD(decltype(f), f)));
584-
});
579+
hpx::execution::experimental::let_value(
580+
[policy = HPX_MOVE(policy)](
581+
auto&& rng, auto&& f) mutable {
582+
return hpx::execution::experimental::just(
583+
hpx::for_each(policy,
584+
HPX_FORWARD(decltype(rng), rng),
585+
HPX_FORWARD(decltype(f), f)));
586+
});
585587
};
586588
}
587589
#endif

libs/core/algorithms/tests/unit/container_algorithms/foreach_tests.hpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -359,10 +359,9 @@ void test_for_each_sender(Policy l, ExPolicy&& p, IteratorTag)
359359
auto result = hpx::get<0>(
360360
// NOLINTNEXTLINE(bugprone-unchecked-optional-access)
361361
*tt::sync_wait(
362-
ex::just(rng, f) |
363-
ex::let_value([](auto&& rng, auto&& f) {
362+
ex::just(rng, f) | ex::let_value([](auto&& rng, auto&& f) {
364363
auto begin_it = rng.begin();
365-
return ex::bulk(ex::just(), ex::par, rng.size(),
364+
return ex::bulk(ex::just(), rng.size(),
366365
[begin_it, f = HPX_FORWARD(decltype(f), f)]
367366
(std::size_t i) mutable {
368367
auto it = begin_it;
@@ -403,10 +402,9 @@ void test_for_each_exception_sender(Policy l, ExPolicy&& p, IteratorTag)
403402
{
404403
using scheduler_t = ex::thread_pool_policy_scheduler<Policy>;
405404
auto result = tt::sync_wait(
406-
ex::just(rng, f) |
407-
ex::let_value([](auto&& rng, auto&& f) {
405+
ex::just(rng, f) | ex::let_value([](auto&& rng, auto&& f) {
408406
auto begin_it = rng.begin();
409-
return ex::bulk(ex::just(), ex::par, rng.size(),
407+
return ex::bulk(ex::just(), rng.size(),
410408
[begin_it, f = HPX_FORWARD(decltype(f), f)]
411409
(std::size_t i) mutable {
412410
auto it = begin_it;
@@ -416,9 +414,12 @@ void test_for_each_exception_sender(Policy l, ExPolicy&& p, IteratorTag)
416414
}));
417415

418416
// If sync_wait returns without exception, check if result indicates error
419-
if (!result.has_value()) {
417+
if (!result.has_value())
418+
{
420419
caught_exception = true;
421-
} else {
420+
}
421+
else
422+
{
422423
HPX_TEST(false);
423424
}
424425
}
@@ -460,10 +461,9 @@ void test_for_each_bad_alloc_sender(Policy l, ExPolicy&& p, IteratorTag)
460461
{
461462
using scheduler_t = ex::thread_pool_policy_scheduler<Policy>;
462463
tt::sync_wait(
463-
ex::just(rng, f) |
464-
ex::let_value([](auto&& rng, auto&& f) {
464+
ex::just(rng, f) | ex::let_value([](auto&& rng, auto&& f) {
465465
auto begin_it = rng.begin();
466-
return ex::bulk(ex::just(), ex::par, rng.size(),
466+
return ex::bulk(ex::just(), rng.size(),
467467
[begin_it, f = HPX_FORWARD(decltype(f), f)]
468468
(std::size_t i) mutable {
469469
auto it = begin_it;

libs/core/execution_base/include/hpx/execution_base/stdexec_forward.hpp

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -151,16 +151,16 @@ namespace hpx::execution::experimental {
151151

152152
// Execution policies for stdexec bulk operations
153153
// Use stdexec's own execution policy types
154-
using stdexec::sequenced_policy;
154+
using stdexec::is_execution_policy;
155+
using stdexec::is_execution_policy_v;
156+
using stdexec::par;
157+
using stdexec::par_unseq;
155158
using stdexec::parallel_policy;
156159
using stdexec::parallel_unsequenced_policy;
157-
using stdexec::unsequenced_policy;
158160
using stdexec::seq;
159-
using stdexec::par;
160-
using stdexec::par_unseq;
161+
using stdexec::sequenced_policy;
161162
using stdexec::unseq;
162-
using stdexec::is_execution_policy;
163-
using stdexec::is_execution_policy_v;
163+
using stdexec::unsequenced_policy;
164164

165165
// Split
166166
using stdexec::split;
@@ -260,7 +260,6 @@ namespace hpx::execution::experimental {
260260
using stdexec::transform_completion_signatures;
261261
using stdexec::transform_completion_signatures_of;
262262

263-
264263
// Transform sender
265264
using stdexec::transform_env;
266265
using stdexec::transform_sender;

libs/core/executors/include/hpx/executors/scheduler_executor.hpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -297,8 +297,8 @@ namespace hpx::execution::experimental {
297297
when_all(keep_future(HPX_FORWARD(Future, predecessor)));
298298

299299
auto loop = bulk(transfer(HPX_MOVE(pre_req), exec.sched_),
300-
hpx::util::size(shape),
301-
hpx::bind_back(HPX_FORWARD(F, f), HPX_FORWARD(Ts, ts)...));
300+
hpx::util::size(shape),
301+
hpx::bind_back(HPX_FORWARD(F, f), HPX_FORWARD(Ts, ts)...));
302302

303303
return make_future(HPX_MOVE(loop));
304304
}
@@ -309,10 +309,10 @@ namespace hpx::execution::experimental {
309309
when_all(keep_future(HPX_FORWARD(Future, predecessor)),
310310
just(std::vector<result_type>(hpx::util::size(shape))));
311311

312-
auto loop =
313-
bulk(transfer(HPX_MOVE(pre_req), exec.sched_), hpx::util::size(shape),
314-
detail::captured_args_then(
315-
HPX_FORWARD(F, f), HPX_FORWARD(Ts, ts)...));
312+
auto loop = bulk(transfer(HPX_MOVE(pre_req), exec.sched_),
313+
hpx::util::size(shape),
314+
detail::captured_args_then(
315+
HPX_FORWARD(F, f), HPX_FORWARD(Ts, ts)...));
316316

317317
return make_future(then(
318318
HPX_MOVE(loop), [](auto&&, std::vector<result_type>&& v) {

libs/core/executors/tests/unit/thread_pool_scheduler.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1930,8 +1930,7 @@ void test_keep_future_sender()
19301930
hpx::get<0>(*(tt::sync_wait(
19311931
ex::when_all(
19321932
ex::keep_future(std::move(f)), ex::keep_future(sf)) |
1933-
ex::transfer(ex::thread_pool_scheduler{}) |
1934-
ex::then(fun)))),
1933+
ex::transfer(ex::thread_pool_scheduler{}) | ex::then(fun))),
19351934
85);
19361935
#else
19371936
HPX_TEST_EQ(hpx::get<0>(*(ex::when_all(ex::keep_future(std::move(f)),

0 commit comments

Comments
 (0)