* decl.c (make_typename_type): s/parameters/arguments/.
[official-gcc.git] / gcc / testsuite / g++.dg / cpp0x / alias-decl-46.C
blob19595ea3cf2f4f873f10219ab23f5b7b8db450ce
1 // PR c++/62134
2 // { dg-do compile { target c++11 } }
4 template<typename... T> struct tuple;
5 template<__SIZE_TYPE__, typename U> struct tuple_element;
7 template<bool, typename T = void> struct enable_if  { };
8 template<typename T> struct enable_if<true, T> { typedef T type; };
10 template <int V> struct int_t { static constexpr int value = V; };
11 template <int V> int constexpr int_t<V>::value;
13 template <class A, class Val, int i=0>
14 struct Index
16     static int const value = -1;
19 template <class ... A, class Val, int i>
20 struct Index<tuple<Val, A ...>, Val, i>
22     static int const value = i;
25 template <class A0, class ... A, class Val, int i>
26 struct Index<tuple<A0, A ...>, Val, i>
28     static int const value = Index<tuple<A ...>, Val, i+1>::value;
31 template <class C, class R> struct PermutationSign;
33 template <int w, class C, class R>
34 struct PermutationSignIfFound
36     static int const value = 0;
39 template <class C, class R>
40 struct PermutationSignIfFound<-1, C, R>
42     static int const value = 0;
45 template <>
46 struct PermutationSign<tuple<>, tuple<>>
48     static int const value = 1;
51 template <class C>
52 struct PermutationSign<C, tuple<>>
54     static int const value = 0;
57 template <class R>
58 struct PermutationSign<tuple<>, R>
60     static int const value = 0;
63 template <class C, class Org>
64 struct PermutationSign
66     static int const value
67     = PermutationSignIfFound
68       <Index<C, typename tuple_element<0, Org>::type>::value,
69        C, Org>::value;
72 template <class A, template <class> class Pred, int i=0, class Enable=void>
73 struct IndexIf
75     static int const value = -1;
76     using type = tuple<>;
79 template <class A0, class ... A, template <class> class Pred, int i>
80 struct IndexIf<tuple<A0, A ...>, Pred, i,
81                typename enable_if<Pred<A0>::value>::type>
83     using type = A0;
84     static int const value = i;
87 template <class A0, class ... A, template <class> class Pred, int i>
88 struct IndexIf<tuple<A0, A ...>, Pred, i,
89                typename enable_if<!Pred<A0>::value>::type>
91     using next = IndexIf<tuple<A ...>, Pred, i+1>;
92     using type = typename next::type;
93     static int const value = next::value;
96 template <class P>
97 struct MatchPermutationP
99     template <class A> using type = PermutationSign<P, A>;
102 template <class P, class Plist> struct FindCombination
104     using type = IndexIf<Plist, MatchPermutationP<P>::template type>;
105     static int const where = type::value;
106     static int const sign
107     = (where>=0) ? PermutationSign<P, typename type::type>::value : 0;
110 int main()
112   using finder = FindCombination<tuple<>, tuple<tuple<>>>;
113   static_assert(finder::where==0 && finder::sign==+1, "bad");