Skip to content

Commit

Permalink
Merge pull request #132 from klevzoff/bugfix/tuple-converting-ctor
Browse files Browse the repository at this point in the history
  • Loading branch information
trws authored May 22, 2023
2 parents 1744f66 + 34b8eca commit 240fb03
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
8 changes: 6 additions & 2 deletions include/camp/tuple.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -326,13 +326,17 @@ struct tuple {
{
}

template <typename... RTypes>
template <typename... RTypes,
typename std::enable_if<
sizeof...(RTypes) == sizeof...(Elements)>::type* = nullptr>
CAMP_HOST_DEVICE constexpr explicit tuple(const tuple<RTypes...>& rhs)
: base(internal::expand_tag{}, rhs)
{
}

template <typename... RTypes>
template <typename... RTypes,
typename std::enable_if<
sizeof...(RTypes) == sizeof...(Elements)>::type* = nullptr>
CAMP_HOST_DEVICE constexpr explicit tuple(tuple<RTypes...>&& rhs)
: base(internal::expand_tag{}, rhs)
{
Expand Down
4 changes: 4 additions & 0 deletions test/tuple.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,10 @@ static_assert(
"can by trivially copy constructed");
#endif

// Test to ensure correct constructor is invoked when constructing from a single tuple argument
static_assert(std::is_same<decltype(camp::make_tuple(camp::make_tuple(A{}, B{}))), camp::tuple<camp::tuple<A, B>>>::value,
"Avoids conversion constructor for a single tuple argument");

// Execution tests

TEST(CampTuple, AssignCompat)
Expand Down

0 comments on commit 240fb03

Please sign in to comment.