1 //===----------------------------------------------------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8
9 // <tuple>
10
11 // template <class... Types> class tuple;
12
13 // tuple(const tuple& u) = default;
14
15 // UNSUPPORTED: c++03
16
17 #include <tuple>
18 #include <string>
19 #include <cassert>
20
21 #include "test_macros.h"
22
23 struct Empty {};
24
main(int,char **)25 int main(int, char**)
26 {
27 {
28 typedef std::tuple<> T;
29 T t0;
30 T t = t0;
31 ((void)t); // Prevent unused warning
32 }
33 {
34 typedef std::tuple<int> T;
35 T t0(2);
36 T t = t0;
37 assert(std::get<0>(t) == 2);
38 }
39 {
40 typedef std::tuple<int, char> T;
41 T t0(2, 'a');
42 T t = t0;
43 assert(std::get<0>(t) == 2);
44 assert(std::get<1>(t) == 'a');
45 }
46 {
47 typedef std::tuple<int, char, std::string> T;
48 const T t0(2, 'a', "some text");
49 T t = t0;
50 assert(std::get<0>(t) == 2);
51 assert(std::get<1>(t) == 'a');
52 assert(std::get<2>(t) == "some text");
53 }
54 #if TEST_STD_VER > 11
55 {
56 typedef std::tuple<int> T;
57 constexpr T t0(2);
58 constexpr T t = t0;
59 static_assert(std::get<0>(t) == 2, "");
60 }
61 {
62 typedef std::tuple<Empty> T;
63 constexpr T t0;
64 constexpr T t = t0;
65 constexpr Empty e = std::get<0>(t);
66 ((void)e); // Prevent unused warning
67 }
68 #endif
69
70 return 0;
71 }
72