]> git.ipfire.org Git - thirdparty/gcc.git/blob - gcc/testsuite/g++.dg/cpp0x/variadic12.C
Regenerate riscv.opt.urls and i386.opt.urls
[thirdparty/gcc.git] / gcc / testsuite / g++.dg / cpp0x / variadic12.C
1 // { dg-do compile { target c++11 } }
2 // A tuple type
3 template<typename... Args> struct tuple { };
4
5 // Determine if two types are the same
6 template<typename T, typename U>
7 struct is_same {
8 static const bool value = false;
9 };
10
11 template<typename T>
12 struct is_same<T, T> {
13 static const bool value = true;
14 };
15
16 // Append 'T' to the end of Tuple
17 template<typename T, typename Tuple>
18 struct append_to_tuple;
19
20 template<typename T, typename... Args>
21 struct append_to_tuple<T, tuple<Args...> > {
22 typedef tuple<Args..., T> type;
23 };
24
25 // Reverse a sequence of arguments (and return the result as a tuple)
26 template<typename... Args> struct reverse;
27
28 template<typename T, typename... Args>
29 struct reverse<T, Args...> {
30 typedef typename append_to_tuple<T, typename reverse<Args...>::type>::type
31 type;
32 };
33
34 template<>
35 struct reverse<> {
36 typedef tuple<> type;
37 };
38
39 int a0[is_same<reverse<>::type, tuple<> >::value? 1 : -1];
40 int a1[is_same<reverse<int>::type, tuple<int> >::value? 1 : -1];
41 int a2[is_same<reverse<char, int>::type, tuple<int, char> >::value? 1 : -1];
42 int a3[is_same<reverse<char, int, long>::type, tuple<long, int, char> >::value? 1 : -1];