Reverting merge from trunk
[official-gcc.git] / libstdc++-v3 / testsuite / 20_util / tuple / creation_functions / constexpr.cc
blobc77860ee7d5114f0dca29637c455aaef07730767
1 // { dg-do compile }
2 // { dg-options "-std=gnu++0x" }
4 // Copyright (C) 2011-2013 Free Software Foundation, Inc.
5 //
6 // This file is part of the GNU ISO C++ Library. This library is free
7 // software; you can redistribute it and/or modify it under the
8 // terms of the GNU General Public License as published by the
9 // Free Software Foundation; either version 3, or (at your option)
10 // any later version.
12 // This library is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 // GNU General Public License for more details.
17 // You should have received a copy of the GNU General Public License along
18 // with this library; see the file COPYING3. If not see
19 // <http://www.gnu.org/licenses/>.
22 // NOTE: This makes use of the fact that we know how moveable
23 // is implemented on pair, and also vector. If the implementation
24 // changes this test may begin to fail.
26 #include <tuple>
28 bool test __attribute__((unused)) = true;
31 // make_tuple
32 void
33 test_make_tuple()
36 typedef std::tuple<int, float> tuple_type;
37 constexpr tuple_type p1 __attribute__((unused))
38 = std::make_tuple(22, 22.222);
42 typedef std::tuple<int, float, int> tuple_type;
43 constexpr tuple_type p1 __attribute__((unused))
44 = std::make_tuple(22, 22.222, 77799);
48 #if 0
49 // forward_as_tuple
50 void
51 test_forward_as_tuple()
54 typedef std::tuple<int, float> tuple_type;
55 constexpr tuple_type p1 __attribute__((unused))
56 = std::forward_as_tuple(22, 22.222);
60 typedef std::tuple<int, float, int> tuple_type;
61 constexpr tuple_type p1 __attribute__((unused))
62 = std::forward_as_tuple(22, 22.222, 77799);
65 #endif
67 #if 0
68 // tie
69 void
70 test_tie()
73 int i(22);
74 float f(22.222);
75 typedef std::tuple<int, float> tuple_type;
76 constexpr tuple_type p1 __attribute__((unused))
77 = std::tie(i, f);
81 int i(22);
82 float f(22.222);
83 int ii(77799);
85 typedef std::tuple<int, float, int> tuple_type;
86 constexpr tuple_type p1 __attribute__((unused))
87 = std::tie(i, f, ii);
90 #endif
92 // get
93 void
94 test_get()
97 typedef std::tuple<int, float> tuple_type;
98 constexpr tuple_type t1 { 55, 77.77 };
99 constexpr auto var __attribute__((unused))
100 = std::get<1>(t1);
104 typedef std::tuple<int, float, int> tuple_type;
105 constexpr tuple_type t1 { 55, 77.77, 99 };
106 constexpr auto var __attribute__((unused))
107 = std::get<2>(t1);
111 // tuple_cat
112 void
113 test_tuple_cat()
115 typedef std::tuple<int, float> tuple_type1;
116 typedef std::tuple<int, int, float> tuple_type2;
118 constexpr tuple_type1 t1 { 55, 77.77 };
119 constexpr tuple_type2 t2 { 55, 99, 77.77 };
120 constexpr auto cat1 __attribute__((unused)) = std::tuple_cat(t1, t2);
124 main()
126 test_make_tuple();
127 test_get();
128 test_tuple_cat();
130 return 0;