1 // { dg-do compile }
2 // { dg-options "-std=gnu++0x" }
3 
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.
11 
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.
16 
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/>.
20 
21 
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.
25 
26 #include <tuple>
27 
28 bool test __attribute__((unused)) = true;
29 
30 
31 // make_tuple
32 void
test_make_tuple()33 test_make_tuple()
34 {
35   {
36     typedef std::tuple<int, float> tuple_type;
37     constexpr tuple_type p1 __attribute__((unused))
38       = std::make_tuple(22, 22.222);
39   }
40 
41   {
42     typedef std::tuple<int, float, int> tuple_type;
43     constexpr tuple_type p1 __attribute__((unused))
44       = std::make_tuple(22, 22.222, 77799);
45   }
46 }
47 
48 #if 0
49 // forward_as_tuple
50 void
51 test_forward_as_tuple()
52 {
53   {
54     typedef std::tuple<int, float> tuple_type;
55     constexpr tuple_type p1 __attribute__((unused))
56       = std::forward_as_tuple(22, 22.222);
57   }
58 
59   {
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);
63   }
64 }
65 #endif
66 
67 #if 0
68 // tie
69 void
70 test_tie()
71 {
72   {
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);
78   }
79 
80   {
81     int i(22);
82     float f(22.222);
83     int ii(77799);
84 
85     typedef std::tuple<int, float, int> tuple_type;
86     constexpr tuple_type p1 __attribute__((unused))
87       = std::tie(i, f, ii);
88   }
89 }
90 #endif
91 
92 // get
93 void
test_get()94 test_get()
95 {
96   {
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);
101   }
102 
103   {
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);
108   }
109 }
110 
111 // tuple_cat
112 void
test_tuple_cat()113 test_tuple_cat()
114 {
115   typedef std::tuple<int, float> 	tuple_type1;
116   typedef std::tuple<int, int, float> tuple_type2;
117 
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);
121 }
122 
123 int
main()124 main()
125 {
126   test_make_tuple();
127   test_get();
128   test_tuple_cat();
129 
130   return 0;
131 }
132