Skip to content

Commit a1c78ec

Browse files
authored
Merge pull request #1725 from RobertLeahy/completion_token_20251229
asioexec::completion_token: Conversion From Mutable Lvalue to Rvalue
2 parents 941f720 + b8a2589 commit a1c78ec

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

include/asioexec/completion_token.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ namespace asioexec {
9292
at_least_as_qualified_v<std::remove_reference_t<T>, std::remove_reference_t<U>>
9393
&& (
9494
// Reference type must agree except...
95-
(std::is_lvalue_reference_v<T> == std::is_lvalue_reference_v<T>) ||
95+
(std::is_lvalue_reference_v<T> == std::is_lvalue_reference_v<U>) ||
9696
// ...special rules for const& which allows rvalues to bind thereto
9797
(std::is_lvalue_reference_v<T> && std::is_const_v<std::remove_reference_t<T>>) ))
9898
#endif

test/asioexec/test_completion_token.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1018,4 +1018,19 @@ namespace {
10181018
CHECK(ctx.stopped());
10191019
}
10201020

1021+
TEST_CASE(
1022+
"Asio operations which declare completion by value but send a mutable lvalue work",
1023+
"[asioexec][completion_token]") {
1024+
const auto initiating_function = [](auto&& token) {
1025+
return asio_impl::async_initiate<decltype(token), void(int)>(
1026+
[](auto&& h) {
1027+
int i = 5;
1028+
std::forward<decltype(h)>(h)(i);
1029+
},
1030+
token);
1031+
};
1032+
auto op = ::stdexec::connect(initiating_function(completion_token), expect_value_receiver{5});
1033+
::stdexec::start(op);
1034+
}
1035+
10211036
} // namespace

0 commit comments

Comments
 (0)