Skip to content
Merged
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
1 change: 1 addition & 0 deletions include/asioexec/completion_token.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -527,6 +527,7 @@ namespace ASIOEXEC_ASIO_NAMESPACE {
template <typename... Signatures>
struct async_result<::asioexec::completion_token_t, Signatures...> {
template <typename Initiation, typename... Args>
requires (std::is_constructible_v<std::decay_t<Args>, Args> && ...)
static constexpr auto
initiate(Initiation&& i, const ::asioexec::completion_token_t&, Args&&... args) {
return ::asioexec::detail::completion_token::sender<
Expand Down
1 change: 1 addition & 0 deletions include/asioexec/use_sender.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,7 @@ namespace ASIOEXEC_ASIO_NAMESPACE {
template <typename... Signatures>
struct async_result<::asioexec::use_sender_t, Signatures...> {
template <typename Initiation, typename... Args>
requires(std::is_constructible_v<std::decay_t<Args>, Args> && ...)
static constexpr auto
initiate(Initiation&& i, const ::asioexec::use_sender_t&, Args&&... args) {
return ::asioexec::detail::use_sender::sender(
Expand Down
21 changes: 21 additions & 0 deletions test/asioexec/test_completion_token.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -997,4 +997,25 @@ namespace {
CHECK(ctx.stopped());
}

TEST_CASE(
"Substitution into async_result<completion_token, ...>::initiate is SFINAE-friendly",
"[asioexec][completion_token]") {
asio_impl::io_context ctx;
asio_impl::ip::tcp::socket socket(ctx);
asio_impl::streambuf buf;
// With a SFINAE-unfriendly async_result<...>::initiate the below line doesn't compile because there's a hard compilation error trying to consider the async_read overload for dynamic buffers
//
// See: https://github.com/NVIDIA/stdexec/issues/1684
auto sender = asio_impl::async_read(socket, buf, completion_token);
auto op = ::stdexec::connect(
std::move(sender) | ::stdexec::then([](const auto ec, const auto bytes_transferred) {
CHECK(ec);
CHECK(!bytes_transferred);
}),
expect_void_receiver{});
::stdexec::start(op);
CHECK(ctx.run() != 0);
CHECK(ctx.stopped());
}

} // namespace
16 changes: 16 additions & 0 deletions test/asioexec/test_use_sender.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -250,4 +250,20 @@ namespace {
CHECK(ctx.stopped());
}

TEST_CASE(
"Substitution into async_result<use_sender, ...>::initiate is SFINAE-friendly",
"[asioexec][completion_token]") {
asio_impl::io_context ctx;
asio_impl::ip::tcp::socket socket(ctx);
asio_impl::streambuf buf;
// With a SFINAE-unfriendly async_result<...>::initiate the below line doesn't compile because there's a hard compilation error trying to consider the async_read overload for dynamic buffers
//
// See: https://github.com/NVIDIA/stdexec/issues/1684
auto sender = asio_impl::async_read(socket, buf, use_sender);
auto op = ::stdexec::connect(std::move(sender), expect_error_receiver{});
::stdexec::start(op);
CHECK(ctx.run() != 0);
CHECK(ctx.stopped());
}

} // namespace
Loading