]> git.ipfire.org Git - thirdparty/gcc.git/blob - libstdc++-v3/testsuite/20_util/tuple/creation_functions/tuple_cat.cc
Update copyright in libstdc++-v3.
[thirdparty/gcc.git] / libstdc++-v3 / testsuite / 20_util / tuple / creation_functions / tuple_cat.cc
1 // { dg-options "-std=gnu++0x" }
2
3 // Copyright (C) 2011-2013 Free Software Foundation, Inc.
4 //
5 // This file is part of the GNU ISO C++ Library. This library is free
6 // software; you can redistribute it and/or modify it under the
7 // terms of the GNU General Public License as published by the
8 // Free Software Foundation; either version 3, or (at your option)
9 // any later version.
10
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
15
16 // You should have received a copy of the GNU General Public License along
17 // with this library; see the file COPYING3. If not see
18 // <http://www.gnu.org/licenses/>.
19
20 // Tuple
21
22 #include <tuple>
23 #include <array>
24
25 static_assert(std::is_same<decltype(std::tuple_cat()),
26 std::tuple<>>::value, "Error");
27 static_assert(std::is_same<decltype(std::tuple_cat
28 (std::declval<std::tuple<>>())),
29 std::tuple<>>::value, "Error");
30 static_assert(std::is_same<decltype(std::tuple_cat
31 (std::declval<std::tuple<>&>())),
32 std::tuple<>>::value, "Error");
33 static_assert(std::is_same<decltype(std::tuple_cat
34 (std::declval<const std::tuple<>>())),
35 std::tuple<>>::value, "Error");
36 static_assert(std::is_same<decltype(std::tuple_cat
37 (std::declval<const std::tuple<>&>())),
38 std::tuple<>>::value, "Error");
39 static_assert(std::is_same<decltype(std::tuple_cat
40 (std::declval<std::pair<int, bool>>())),
41 std::tuple<int, bool>>::value, "Error");
42 static_assert(std::is_same<decltype(std::tuple_cat
43 (std::declval<std::pair<int, bool>&>())),
44 std::tuple<int, bool>>::value, "Error");
45 static_assert(std::is_same<decltype
46 (std::tuple_cat(std::declval<const std::pair<int, bool>>())),
47 std::tuple<int, bool>>::value, "Error");
48 static_assert(std::is_same<decltype
49 (std::tuple_cat(std::declval<const std::pair<int, bool>&>())),
50 std::tuple<int, bool>>::value, "Error");
51 static_assert(std::is_same<decltype
52 (std::tuple_cat(std::declval<std::array<int, 3>>())),
53 std::tuple<int, int, int>>::value, "Error");
54 static_assert(std::is_same<decltype
55 (std::tuple_cat(std::declval<std::array<int, 3>&>())),
56 std::tuple<int, int, int>>::value, "Error");
57 static_assert(std::is_same<decltype
58 (std::tuple_cat(std::declval<const std::array<int, 3>>())),
59 std::tuple<int, int, int>>::value, "Error");
60 static_assert(std::is_same<decltype
61 (std::tuple_cat(std::declval<const std::array<int, 3>&>())),
62 std::tuple<int, int, int>>::value, "Error");
63 static_assert(std::is_same<decltype
64 (std::tuple_cat
65 (std::declval<std::tuple<>>(), std::declval<std::tuple<>>())),
66 std::tuple<>>::value, "Error");
67 static_assert(std::is_same<decltype
68 (std::tuple_cat
69 (std::declval<std::tuple<>>(), std::declval<std::tuple<>>(),
70 std::declval<std::tuple<>>())), std::tuple<>>::value, "Error");
71 static_assert(std::is_same<decltype
72 (std::tuple_cat
73 (std::declval<std::tuple<>>(),
74 std::declval<std::array<char, 0>>(),
75 std::declval<std::array<int, 0>>(),
76 std::declval<std::tuple<>>())), std::tuple<>>::value, "Error");
77 static_assert(std::is_same<decltype
78 (std::tuple_cat
79 (std::declval<std::tuple<int>>(),
80 std::declval<std::tuple<double>>())),
81 std::tuple<int, double>>::value, "Error");
82 static_assert(std::is_same<decltype
83 (std::tuple_cat
84 (std::declval<std::tuple<int>>(),
85 std::declval<std::tuple<double>>(),
86 std::declval<std::tuple<const long&>>())),
87 std::tuple<int, double, const long&>>::value, "Error");
88 static_assert(std::is_same<decltype
89 (std::tuple_cat
90 (std::declval<std::array<wchar_t, 3>&>(),
91 std::declval<std::tuple<double>>(),
92 std::declval<std::tuple<>>(),
93 std::declval<std::tuple<unsigned&>>(),
94 std::declval<std::pair<bool, std::nullptr_t>>())),
95 std::tuple<wchar_t, wchar_t, wchar_t,
96 double, unsigned&, bool, std::nullptr_t>
97 >::value, "Error");
98
99 int main()
100 {
101 std::tuple_cat();
102 std::tuple_cat(std::tuple<>{ });
103 std::tuple_cat(std::tuple<>{ }, std::tuple<>{ });
104 std::array<int, 3> a3;
105 std::tuple_cat(a3);
106 std::pair<double, bool> pdb;
107 std::tuple<unsigned, float, std::nullptr_t, void*> t;
108 int i{ };
109 double d{ };
110 int* pi{ };
111 std::tuple<int&, double&, int*&> to{i, d, pi};
112 std::tuple_cat(pdb);
113 std::tuple_cat(to);
114 std::tuple_cat(to, to);
115 std::tuple_cat(a3, pdb);
116 std::tuple_cat(a3, pdb, t);
117 std::tuple_cat(a3, pdb, t, a3);
118 std::tuple_cat(a3, pdb, t, a3, pdb, t);
119
120 static_assert(std::is_same<decltype
121 (std::tuple_cat(a3, pdb, t, a3, pdb, t)),
122 std::tuple<int, int, int, double, bool,
123 unsigned, float, std::nullptr_t, void*,
124 int, int, int, double, bool, unsigned,
125 float, std::nullptr_t, void*>
126 >::value, "Error");
127
128 std::tuple_cat(std::tuple<int, char, void*>{}, to, a3,
129 std::tuple<>{}, std::pair<float,
130 std::nullptr_t>{}, pdb, to);
131 }