Skip to content

Commit c587808

Browse files
authored
Fix missing move in let value (#187)
* added a missing move in the let_value implementation (issue-186) * removed some left-over code from identifying the issue * added a missing newline at the end of the file
1 parent 0e40e91 commit c587808

File tree

3 files changed

+36
-1
lines changed

3 files changed

+36
-1
lines changed

include/beman/execution/detail/let.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ struct impls_for<::beman::execution::detail::let_t<Completion>> : ::beman::execu
167167
auto mkop{[&] {
168168
return ::beman::execution::connect(
169169
::std::apply(::std::move(state.fun),
170-
state.args.template emplace<args_t>(::std::forward<Args>(args)...)),
170+
::std::move(state.args.template emplace<args_t>(::std::forward<Args>(args)...))),
171171
let_receiver<Receiver, decltype(state.env)>{receiver, state.env});
172172
}};
173173
::beman::execution::start(

tests/beman/execution/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ list(
1313
APPEND
1414
execution_tests
1515
issue-174.test
16+
issue-186.test
1617
exec-scope-counting.test
1718
exec-spawn.test
1819
exec-stop-when.test
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#include <beman/execution/execution.hpp>
2+
#include <cassert>
3+
4+
namespace ex = beman::execution;
5+
6+
namespace {
7+
struct move_only_type {
8+
move_only_type() : val(0) {}
9+
explicit move_only_type(int v) : val(v) {}
10+
~move_only_type() = default;
11+
12+
move_only_type(const move_only_type&) = delete;
13+
move_only_type& operator=(const move_only_type&) = delete;
14+
15+
move_only_type& operator=(move_only_type&&) = default;
16+
move_only_type(move_only_type&&) = default;
17+
int val; // NOLINT
18+
};
19+
} // namespace
20+
21+
int main() {
22+
auto snd = ex::just(move_only_type(1)) //
23+
| ex::then([](move_only_type v) noexcept { return v.val * 2; }) //
24+
| ex::let_value([](int v) noexcept { return ex::just(v * 3); }); // int
25+
auto [ret] = ex::sync_wait(std::move(snd)).value();
26+
assert(ret == 6);
27+
28+
// NOTE: Compile time error with move_only_type
29+
auto snd2 = ex::just(move_only_type(1)) //
30+
| ex::then([](move_only_type v) noexcept { return move_only_type{v.val * 2}; }) //
31+
| ex::let_value([](move_only_type v) noexcept { return ex::just(v.val * 3); }); // move_only_type
32+
auto [ret2] = ex::sync_wait(std::move(snd2)).value();
33+
assert(ret2 == 6);
34+
}

0 commit comments

Comments
 (0)