xref: /aosp_15_r20/external/libcxx/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/copy.pass.cpp (revision 58b9f456b02922dfdb1fad8a988d5fd8765ecb80)
1 //===----------------------------------------------------------------------===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is dual licensed under the MIT and the University of Illinois Open
6 // Source Licenses. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 
10 // <tuple>
11 
12 // template <class... Types> class tuple;
13 
14 // tuple(const tuple& u) = default;
15 
16 // UNSUPPORTED: c++98, c++03
17 
18 #include <tuple>
19 #include <string>
20 #include <cassert>
21 
22 #include "test_macros.h"
23 
24 struct Empty {};
25 
main()26 int main()
27 {
28     {
29         typedef std::tuple<> T;
30         T t0;
31         T t = t0;
32         ((void)t); // Prevent unused warning
33     }
34     {
35         typedef std::tuple<int> T;
36         T t0(2);
37         T t = t0;
38         assert(std::get<0>(t) == 2);
39     }
40     {
41         typedef std::tuple<int, char> T;
42         T t0(2, 'a');
43         T t = t0;
44         assert(std::get<0>(t) == 2);
45         assert(std::get<1>(t) == 'a');
46     }
47     {
48         typedef std::tuple<int, char, std::string> T;
49         const T t0(2, 'a', "some text");
50         T t = t0;
51         assert(std::get<0>(t) == 2);
52         assert(std::get<1>(t) == 'a');
53         assert(std::get<2>(t) == "some text");
54     }
55 #if TEST_STD_VER > 11
56     {
57         typedef std::tuple<int> T;
58         constexpr T t0(2);
59         constexpr T t = t0;
60         static_assert(std::get<0>(t) == 2, "");
61     }
62     {
63         typedef std::tuple<Empty> T;
64         constexpr T t0;
65         constexpr T t = t0;
66         constexpr Empty e = std::get<0>(t);
67         ((void)e); // Prevent unused warning
68     }
69 #endif
70 }
71