1 //===----------------------------------------------------------------------===//
3 // The LLVM Compiler Infrastructure
5 // This file is dual licensed under the MIT and the University of Illinois Open
6 // Source Licenses. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
12 // template <class... Types> class tuple;
14 // template <class... UTypes> tuple(const tuple<UTypes...>& u);
16 // UNSUPPORTED: c++98, c++03
23 #include "test_macros.h"
27 explicit Explicit(int x) : value(x) {}
32 Implicit(int x) : value(x) {}
39 explicit B(int i) : id_(i) {}
45 explicit D(int i) : B(i) {}
54 constexpr A(int i) : id_(i) {}
55 friend constexpr bool operator==(const A& x, const A& y) {return x.id_ == y.id_;}
62 constexpr explicit C(int i) : id_(i) {}
63 friend constexpr bool operator==(const C& x, const C& y) {return x.id_ == y.id_;}
71 typedef std::tuple<long> T0;
72 typedef std::tuple<long long> T1;
75 assert(std::get<0>(t1) == 2);
79 typedef std::tuple<int> T0;
80 typedef std::tuple<A> T1;
83 static_assert(std::get<0>(t1) == 2, "");
86 typedef std::tuple<int> T0;
87 typedef std::tuple<C> T1;
90 static_assert(std::get<0>(t1) == C(2), "");
94 typedef std::tuple<long, char> T0;
95 typedef std::tuple<long long, int> T1;
98 assert(std::get<0>(t1) == 2);
99 assert(std::get<1>(t1) == int('a'));
102 typedef std::tuple<long, char, D> T0;
103 typedef std::tuple<long long, int, B> T1;
106 assert(std::get<0>(t1) == 2);
107 assert(std::get<1>(t1) == int('a'));
108 assert(std::get<2>(t1).id_ == 3);
112 typedef std::tuple<long, char, D&> T0;
113 typedef std::tuple<long long, int, B&> T1;
117 assert(std::get<0>(t1) == 2);
118 assert(std::get<1>(t1) == int('a'));
119 assert(std::get<2>(t1).id_ == 2);
122 typedef std::tuple<long, char, int> T0;
123 typedef std::tuple<long long, int, B> T1;
126 assert(std::get<0>(t1) == 2);
127 assert(std::get<1>(t1) == int('a'));
128 assert(std::get<2>(t1).id_ == 3);
131 const std::tuple<int> t1(42);
132 std::tuple<Explicit> t2(t1);
133 assert(std::get<0>(t2).value == 42);
136 const std::tuple<int> t1(42);
137 std::tuple<Implicit> t2 = t1;
138 assert(std::get<0>(t2).value == 42);