From 1a3ba6eff9b5472db14ecd0147b7907f98b62112 Mon Sep 17 00:00:00 2001 From: Auriane R Date: Tue, 4 Oct 2022 11:07:24 +0200 Subject: [PATCH 1/2] Add failing test with const_reference_sender --- .../tests/unit/algorithm_let_value.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/libs/pika/execution/tests/unit/algorithm_let_value.cpp b/libs/pika/execution/tests/unit/algorithm_let_value.cpp index be56f87abd..59edfaa6c3 100644 --- a/libs/pika/execution/tests/unit/algorithm_let_value.cpp +++ b/libs/pika/execution/tests/unit/algorithm_let_value.cpp @@ -98,6 +98,24 @@ int main() PIKA_TEST(let_value_callback_called); } + { + std::atomic set_value_called{false}; + std::atomic let_value_callback_called{false}; + int x = 42; + auto s1 = const_reference_sender{x}; + auto s2 = ex::let_value(std::move(s1), [&](auto& x) { + PIKA_TEST_EQ(x, 42); + let_value_callback_called = true; + return ex::just(x); + }); + auto f = [](int x) { PIKA_TEST_EQ(x, 42); }; + auto r = callback_receiver{f, set_value_called}; + auto os = ex::connect(std::move(s2), std::move(r)); + ex::start(os); + PIKA_TEST(set_value_called); + PIKA_TEST(let_value_callback_called); + } + // operator| overload { std::atomic set_value_called{false}; From 46e53ba27f9b675fef4fdae8884356001eb73ae5 Mon Sep 17 00:00:00 2001 From: Auriane R Date: Tue, 4 Oct 2022 12:16:54 +0200 Subject: [PATCH 2/2] Attempt to fix const ref handling --- .../pika/execution/algorithms/let_value.hpp | 22 +++++++++++++------ 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/libs/pika/execution/include/pika/execution/algorithms/let_value.hpp b/libs/pika/execution/include/pika/execution/algorithms/let_value.hpp index 730f121889..eca49eb971 100644 --- a/libs/pika/execution/include/pika/execution/algorithms/let_value.hpp +++ b/libs/pika/execution/include/pika/execution/algorithms/let_value.hpp @@ -47,12 +47,19 @@ namespace pika::let_value_detail { predecessor_sender; PIKA_NO_UNIQUE_ADDRESS std::decay_t f; + template + struct predecessor_value_types_helper + { + using type = pika::util::detail::transform_t; + }; + // Type of the potential values returned from the predecessor sender template