From 89479eca1f53e3c0c00e96492c41d9735581e818 Mon Sep 17 00:00:00 2001 From: Auriane R Date: Thu, 6 Oct 2022 11:19:04 +0200 Subject: [PATCH 1/2] Add a const reference handling test for start_detached --- .../execution/tests/unit/algorithm_start_detached.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/libs/pika/execution/tests/unit/algorithm_start_detached.cpp b/libs/pika/execution/tests/unit/algorithm_start_detached.cpp index 981ef84258..6fae09baa7 100644 --- a/libs/pika/execution/tests/unit/algorithm_start_detached.cpp +++ b/libs/pika/execution/tests/unit/algorithm_start_detached.cpp @@ -49,6 +49,17 @@ int main() PIKA_TEST(!tag_invoke_overload_called); } + { + int x = 42; + std::atomic then_called{false}; + ex::start_detached( + const_reference_sender{x} | ex::then([&](auto& x) { + PIKA_TEST_EQ(x, 42); + then_called = true; + })); + PIKA_TEST(then_called); + } + { std::atomic start_called{false}; std::atomic connect_called{false}; From e344f07140e7a464f5beffab0ebceca762b5bc74 Mon Sep 17 00:00:00 2001 From: aurianer Date: Mon, 10 Oct 2022 16:17:44 +0200 Subject: [PATCH 2/2] Simplify the test with const_reference_sender --- .../execution/tests/unit/algorithm_start_detached.cpp | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/libs/pika/execution/tests/unit/algorithm_start_detached.cpp b/libs/pika/execution/tests/unit/algorithm_start_detached.cpp index 6fae09baa7..48c491688f 100644 --- a/libs/pika/execution/tests/unit/algorithm_start_detached.cpp +++ b/libs/pika/execution/tests/unit/algorithm_start_detached.cpp @@ -51,13 +51,7 @@ int main() { int x = 42; - std::atomic then_called{false}; - ex::start_detached( - const_reference_sender{x} | ex::then([&](auto& x) { - PIKA_TEST_EQ(x, 42); - then_called = true; - })); - PIKA_TEST(then_called); + ex::start_detached(const_reference_sender{x}); } {