Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix result type computation in exec::when_any #978

Merged
merged 1 commit into from
Jun 17, 2023
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
2 changes: 1 addition & 1 deletion include/exec/when_any.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ namespace exec {
// transform Tag(Args...) to a tuple __decayed_tuple<Tag, Args...>
template <class _Env, class... _SenderIds>
using __result_type_t = __mapply<
__transform<__q<__signature_to_tuple_t>, __q<std::variant>>,
__transform<__q<__signature_to_tuple_t>, __munique<__q<std::variant>>>,
__completion_signatures_t<_Env, _SenderIds...>>;

template <class _Variant, class... _Ts>
Expand Down
22 changes: 22 additions & 0 deletions test/exec/test_when_any.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -210,3 +210,25 @@ TEST_CASE("when_any completion signatures", "[adaptors][when_any]") {
set_error_t(std::exception_ptr)>>>);
// wait_for_value(std::move(snd), movable(42));
}

template <class Receiver>
struct dup_op {
Receiver rec;
friend void tag_invoke(start_t, dup_op& self) noexcept {
stdexec::set_error(static_cast<Receiver&&>(self.rec), std::make_exception_ptr(std::runtime_error("dup")));
}
};

struct dup_sender {
using is_sender = void;
using completion_signatures = stdexec::completion_signatures<set_value_t(), set_error_t(std::exception_ptr), set_error_t(std::exception_ptr&&)>;

template <class Receiver>
friend dup_op<Receiver> tag_invoke(connect_t, dup_sender, Receiver rec) noexcept {
return {static_cast<Receiver&&>(rec)};
}
};

TEST_CASE("when_any - with duplicate completions", "[adaptors][when_any]") {
REQUIRE_THROWS(stdexec::sync_wait(exec::when_any(dup_sender{})));
}