From fc9056e2ab2d8f77a3955196094b1e25b7b8aba4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dietmar=20K=C3=BChl?= Date: Sat, 11 Oct 2025 12:47:47 +0100 Subject: [PATCH 1/3] added a missing move in the let_value implementation (issue-186) --- include/beman/execution/detail/let.hpp | 3 ++- tests/beman/execution/CMakeLists.txt | 1 + tests/beman/execution/issue-186.test.cpp | 34 ++++++++++++++++++++++++ 3 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 tests/beman/execution/issue-186.test.cpp diff --git a/include/beman/execution/detail/let.hpp b/include/beman/execution/detail/let.hpp index 1158f933..e13176b1 100644 --- a/include/beman/execution/detail/let.hpp +++ b/include/beman/execution/detail/let.hpp @@ -165,9 +165,10 @@ struct impls_for<::beman::execution::detail::let_t> : ::beman::execu static auto let_bind(auto& state, Receiver& receiver, Args&&... args) { using args_t = ::beman::execution::detail::decayed_tuple; auto mkop{[&] { + state.args.template emplace(::std::forward(args)...); return ::beman::execution::connect( ::std::apply(::std::move(state.fun), - state.args.template emplace(::std::forward(args)...)), + ::std::move(state.args.template emplace(::std::forward(args)...))), let_receiver{receiver, state.env}); }}; ::beman::execution::start( diff --git a/tests/beman/execution/CMakeLists.txt b/tests/beman/execution/CMakeLists.txt index 696ec350..00b1683f 100644 --- a/tests/beman/execution/CMakeLists.txt +++ b/tests/beman/execution/CMakeLists.txt @@ -13,6 +13,7 @@ list( APPEND execution_tests issue-174.test + issue-186.test exec-scope-counting.test exec-spawn.test exec-stop-when.test diff --git a/tests/beman/execution/issue-186.test.cpp b/tests/beman/execution/issue-186.test.cpp new file mode 100644 index 00000000..b62a191b --- /dev/null +++ b/tests/beman/execution/issue-186.test.cpp @@ -0,0 +1,34 @@ +#include +#include + +namespace ex = beman::execution; + +namespace { +struct move_only_type { + move_only_type() : val(0) {} + explicit move_only_type(int v) : val(v) {} + ~move_only_type() = default; + + move_only_type(const move_only_type&) = delete; + move_only_type& operator=(const move_only_type&) = delete; + + move_only_type& operator=(move_only_type&&) = default; + move_only_type(move_only_type&&) = default; + int val; // NOLINT +}; +} // namespace + +int main() { + auto snd = ex::just(move_only_type(1)) // + | ex::then([](move_only_type v) noexcept { return v.val * 2; }) // + | ex::let_value([](int v) noexcept { return ex::just(v * 3); }); // int + auto [ret] = ex::sync_wait(std::move(snd)).value(); + assert(ret == 6); + + // NOTE: Compile time error with move_only_type + auto snd2 = ex::just(move_only_type(1)) // + | ex::then([](move_only_type v) noexcept { return move_only_type{v.val * 2}; }) // + | ex::let_value([](move_only_type v) noexcept { return ex::just(v.val * 3); }); // move_only_type + auto [ret2] = ex::sync_wait(std::move(snd2)).value(); + assert(ret2 == 6); +} \ No newline at end of file From 1ddd6fbeed94f2254a7927efca0313d2a9e724d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dietmar=20K=C3=BChl?= Date: Sat, 11 Oct 2025 12:49:15 +0100 Subject: [PATCH 2/3] removed some left-over code from identifying the issue --- include/beman/execution/detail/let.hpp | 1 - 1 file changed, 1 deletion(-) diff --git a/include/beman/execution/detail/let.hpp b/include/beman/execution/detail/let.hpp index e13176b1..499210af 100644 --- a/include/beman/execution/detail/let.hpp +++ b/include/beman/execution/detail/let.hpp @@ -165,7 +165,6 @@ struct impls_for<::beman::execution::detail::let_t> : ::beman::execu static auto let_bind(auto& state, Receiver& receiver, Args&&... args) { using args_t = ::beman::execution::detail::decayed_tuple; auto mkop{[&] { - state.args.template emplace(::std::forward(args)...); return ::beman::execution::connect( ::std::apply(::std::move(state.fun), ::std::move(state.args.template emplace(::std::forward(args)...))), From 4bf16e14e48906470af358bcc11427a6f8932288 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dietmar=20K=C3=BChl?= Date: Sat, 11 Oct 2025 12:52:40 +0100 Subject: [PATCH 3/3] added a missing newline at the end of the file --- tests/beman/execution/issue-186.test.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/beman/execution/issue-186.test.cpp b/tests/beman/execution/issue-186.test.cpp index b62a191b..fcb4972f 100644 --- a/tests/beman/execution/issue-186.test.cpp +++ b/tests/beman/execution/issue-186.test.cpp @@ -31,4 +31,4 @@ int main() { | ex::let_value([](move_only_type v) noexcept { return ex::just(v.val * 3); }); // move_only_type auto [ret2] = ex::sync_wait(std::move(snd2)).value(); assert(ret2 == 6); -} \ No newline at end of file +}