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
5 changes: 3 additions & 2 deletions include/stdexec/__detail/__into_variant.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,9 @@ namespace STDEXEC
STDEXEC_TRY
{
STDEXEC::set_value(static_cast<_State&&>(__state).__rcvr_,
__variant_t{
std::tuple<_Args&&...>{static_cast<_Args&&>(__args)...}});
__variant_t{std::in_place_type<__decayed_std_tuple<_Args...>>,
std::tuple<_Args&&...>{
static_cast<_Args&&>(__args)...}});
}
STDEXEC_CATCH_ALL
{
Expand Down
14 changes: 11 additions & 3 deletions include/stdexec/__detail/__when_all.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,16 @@ namespace STDEXEC

struct when_all_with_variant_t
{
private:
static constexpr auto __mk_transform_fn() noexcept
{
return []<class... _Child>(__ignore, __ignore, _Child&&... __child)
{
return when_all(into_variant(static_cast<_Child&&>(__child))...);
};
}

public:
template <sender... _Senders>
constexpr auto operator()(_Senders&&... __sndrs) const -> __well_formed_sender auto
{
Expand All @@ -66,9 +76,7 @@ namespace STDEXEC
static constexpr auto transform_sender(set_value_t, _Sender&& __sndr, __ignore)
{
// transform when_all_with_variant(sndrs...) into when_all(into_variant(sndrs)...).
return __apply([&]<class... _Child>(__ignore, __ignore, _Child&&... __child)
{ return when_all(into_variant(static_cast<_Child&&>(__child))...); },
static_cast<_Sender&&>(__sndr));
return __apply(__mk_transform_fn(), static_cast<_Sender&&>(__sndr));
}
};

Expand Down
10 changes: 10 additions & 0 deletions test/stdexec/algos/adaptors/test_when_all.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/

#include <catch2/catch.hpp>
#include <exec/any_sender_of.hpp>
#include <exec/async_scope.hpp>
#include <exec/env.hpp>
#include <exec/sender_for.hpp>
Expand Down Expand Up @@ -461,4 +462,13 @@ namespace
scope.request_stop();
ex::sync_wait(scope.on_empty());
}

TEST_CASE("regression test for #1988", "[adaptors][when_all")
{
// just test that this compiles:
using any_sender = exec::any_sender<
exec::any_receiver<ex::completion_signatures<ex::set_value_t(int), ex::set_value_t(double)>>>;
ex::sync_wait(ex::when_all_with_variant(any_sender{ex::just(1)}));
SUCCEED();
}
} // namespace
Loading