Skip to content

Commit e6cfe71

Browse files
WIP
1 parent 7a3d904 commit e6cfe71

File tree

1 file changed

+73
-1
lines changed

1 file changed

+73
-1
lines changed

libcxx/test/std/utilities/tuple/tuple.tuple/tuple.creation/tuple_cat.pass.cpp

Lines changed: 73 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,70 @@ template<typename ...Ts>
3131
void forward_as_tuple(Ts...) = delete;
3232
}
3333

34+
// https://github.com/llvm/llvm-project/issues/41034
35+
struct Unconstrained {
36+
int data;
37+
template <typename Arg>
38+
TEST_CONSTEXPR_CXX14 Unconstrained(Arg arg) : data(arg) {}
39+
};
40+
41+
TEST_CONSTEXPR_CXX14 std::tuple<Unconstrained> test_cat_unary_lvalue() {
42+
auto tup = std::tuple<Unconstrained>(Unconstrained(5));
43+
return std::tuple_cat(tup);
44+
}
45+
46+
TEST_CONSTEXPR_CXX14 std::tuple<Unconstrained> test_cat_unary_rvalue() {
47+
return std::tuple_cat(std::tuple<Unconstrained>(Unconstrained(6)));
48+
}
49+
50+
TEST_CONSTEXPR_CXX14 std::tuple<Unconstrained> test_cat_unary_and_nullary() {
51+
return std::tuple_cat(std::tuple<Unconstrained>(Unconstrained(7)), std::tuple<>());
52+
}
53+
54+
#if TEST_STD_VER >= 17
55+
constexpr auto test_cat_unary_lvalue_ctad() {
56+
auto tup = std::tuple(Unconstrained(8));
57+
return std::tuple_cat(tup);
58+
}
59+
60+
constexpr auto test_cat_unary_rvalue_ctad() { return std::tuple_cat(std::tuple(Unconstrained(9))); }
61+
62+
constexpr auto test_cat_unary_and_nullary_ctad() { return std::tuple_cat(std::tuple(Unconstrained(10)), std::tuple()); }
63+
#endif
64+
65+
TEST_CONSTEXPR_CXX14 bool test_tuple_cat_with_unconstrained_constructor() {
66+
{
67+
auto tup = test_cat_unary_lvalue();
68+
assert(std::get<0>(tup).data == 5);
69+
}
70+
{
71+
auto tup = test_cat_unary_rvalue();
72+
assert(std::get<0>(tup).data == 6);
73+
}
74+
{
75+
auto tup = test_cat_unary_and_nullary();
76+
assert(std::get<0>(tup).data == 7);
77+
}
78+
#if TEST_STD_VER >= 17
79+
{
80+
auto tup = test_cat_unary_lvalue_ctad();
81+
ASSERT_SAME_TYPE(decltype(tup), std::tuple<Unconstrained>);
82+
assert(std::get<0>(tup).data == 8);
83+
}
84+
{
85+
auto tup = test_cat_unary_rvalue_ctad();
86+
ASSERT_SAME_TYPE(decltype(tup), std::tuple<Unconstrained>);
87+
assert(std::get<0>(tup).data == 9);
88+
}
89+
{
90+
auto tup = test_cat_unary_and_nullary_ctad();
91+
ASSERT_SAME_TYPE(decltype(tup), std::tuple<Unconstrained>);
92+
assert(std::get<0>(tup).data == 10);
93+
}
94+
#endif
95+
return true;
96+
}
97+
3498
int main(int, char**)
3599
{
36100
{
@@ -270,5 +334,13 @@ int main(int, char**)
270334
assert(std::get<0>(t).i == 1);
271335
assert(std::get<0>(t2).i == 1);
272336
}
273-
return 0;
337+
// See https://github.com/llvm/llvm-project/issues/41034
338+
{
339+
test_tuple_cat_with_unconstrained_constructor();
340+
#if TEST_STD_VER >= 14
341+
static_assert(test_tuple_cat_with_unconstrained_constructor(), "");
342+
#endif
343+
}
344+
345+
return 0;
274346
}

0 commit comments

Comments
 (0)