]> git.ipfire.org Git - thirdparty/gcc.git/blob - libstdc++-v3/testsuite/20_util/tuple/creation_functions/48476.cc
Use effective-target instead of -std options
[thirdparty/gcc.git] / libstdc++-v3 / testsuite / 20_util / tuple / creation_functions / 48476.cc
1 // { dg-do run { target c++11 } }
2
3 // Copyright (C) 2011-2016 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 #include <tuple>
21 #include <type_traits>
22 #include <testsuite_hooks.h>
23
24 template<typename T>
25 typename std::decay<T>::type copy(T&& x)
26 { return std::forward<T>(x); }
27
28 template<typename... Args1, typename... Args2>
29 void
30 check_tuple_cat(std::tuple<Args1...> t1, std::tuple<Args2...> t2)
31 {
32 bool test __attribute__((unused)) = true;
33
34 typedef std::tuple<Args1..., Args2...> concatenated;
35
36 auto cat1 = std::tuple_cat( t1, t2 );
37 auto cat2 = std::tuple_cat(copy(t1), t2 );
38 auto cat3 = std::tuple_cat( t1, copy(t2));
39 auto cat4 = std::tuple_cat(copy(t1), copy(t2));
40
41 static_assert( std::is_same<decltype(cat1), concatenated>::value, "" );
42 static_assert( std::is_same<decltype(cat2), concatenated>::value, "" );
43 static_assert( std::is_same<decltype(cat3), concatenated>::value, "" );
44 static_assert( std::is_same<decltype(cat4), concatenated>::value, "" );
45
46 VERIFY( cat1 == cat2 );
47 VERIFY( cat1 == cat3 );
48 VERIFY( cat1 == cat4 );
49 }
50
51 // libstdc++/48476
52 void test01()
53 {
54 int i = 0;
55 std::tuple<> t0;
56 std::tuple<int&> t1(i);
57 std::tuple<int&, int> t2(i, 0);
58 std::tuple<int const&, int, double> t3(i, 0, 0);
59
60 check_tuple_cat(t0, t0);
61 check_tuple_cat(t0, t1);
62 check_tuple_cat(t0, t2);
63 check_tuple_cat(t0, t3);
64
65 check_tuple_cat(t1, t0);
66 check_tuple_cat(t1, t1);
67 check_tuple_cat(t1, t2);
68 check_tuple_cat(t1, t3);
69
70 check_tuple_cat(t2, t0);
71 check_tuple_cat(t2, t1);
72 check_tuple_cat(t2, t2);
73 check_tuple_cat(t2, t3);
74
75 check_tuple_cat(t3, t0);
76 check_tuple_cat(t3, t1);
77 check_tuple_cat(t3, t2);
78 check_tuple_cat(t3, t3);
79 }
80
81 int main()
82 {
83 test01();
84 return 0;
85 }