Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion include/asioexec/completion_token.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ namespace asioexec {
at_least_as_qualified_v<std::remove_reference_t<T>, std::remove_reference_t<U>>
&& (
// Reference type must agree except...
(std::is_lvalue_reference_v<T> == std::is_lvalue_reference_v<T>) ||
(std::is_lvalue_reference_v<T> == std::is_lvalue_reference_v<U>) ||
// ...special rules for const& which allows rvalues to bind thereto
(std::is_lvalue_reference_v<T> && std::is_const_v<std::remove_reference_t<T>>) ))
#endif
Expand Down
15 changes: 15 additions & 0 deletions test/asioexec/test_completion_token.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1018,4 +1018,19 @@ namespace {
CHECK(ctx.stopped());
}

TEST_CASE(
"Asio operations which declare completion by value but send a mutable lvalue work",
"[asioexec][completion_token]") {
const auto initiating_function = [](auto&& token) {
return asio_impl::async_initiate<decltype(token), void(int)>(
[](auto&& h) {
int i = 5;
std::forward<decltype(h)>(h)(i);
},
token);
};
auto op = ::stdexec::connect(initiating_function(completion_token), expect_value_receiver{5});
::stdexec::start(op);
}

} // namespace
Loading