Skip to content

Commit

Permalink
Allow copying/movingvariant_sender
Browse files Browse the repository at this point in the history
variant_sender's perfect forwarding constructor hid the move and copy
constructors.
  • Loading branch information
ccotter committed Jan 3, 2024
1 parent 4724b8d commit b729180
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
3 changes: 2 additions & 1 deletion include/unifex/variant_sender.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,8 @@ class _sender<Senders...>::type {
static constexpr bool is_always_scheduler_affine =
(sender_traits<Senders>::is_always_scheduler_affine && ...);

template <typename ConcreteSender>
template (typename ConcreteSender)
(requires is_one_of_v<std::decay_t<ConcreteSender>, Senders...>)
type(ConcreteSender&& concreteSender) noexcept(
std::is_nothrow_constructible_v<
std::variant<Senders...>,
Expand Down
6 changes: 6 additions & 0 deletions test/variant_sender_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -283,3 +283,9 @@ TEST(Variant, TestMSVCCpp20RegressionScenario) {

ASSERT_TRUE(ret.has_value());
}

TEST(Variant, CopyableAndMovable) {
variant_sender<decltype(just(5)), decltype(just(1.0))> just_variant_sender(just(5));
auto other = just_variant_sender;
other = std::move(just_variant_sender);
}

0 comments on commit b729180

Please sign in to comment.