1 // PR c++/90227
2 // { dg-do compile { target c++14 } }
3 
4 template <int b> struct c { static constexpr int d = b; typedef c e; };
5 template <bool, typename a> using f = a;
6 template <bool g> using h = c<g>;
7 template <int g> using i = c<g>;
8 template <typename...> struct ab {};
9 template <typename... j> struct k { using e = ab<j...>; };
10 template <typename> struct ad;
11 template <typename j, typename... l> struct ad<ab<j, l...>> { using e = ab<l...>; };
12 template <typename> struct ae;
13 template <typename... m> struct ae<ab<m...>> : i<sizeof...(m)> {};
14 template <typename af, int, int = ae<af>::d> struct ag;
15 template <typename... m> struct ag<ab<m...>, 0, 0> { using e = ab<>; };
16 template <typename... m, int ah>
17 struct ag<ab<m...>, 0, ah> : k<typename ag<typename ad<ab<m...>>::e, ah - 1>::e> {};
18 template <typename... m, int ai, int ah>
19 struct ag<ab<m...>, ai, ah> : ag<typename ad<ab<m...>>::e, ai - 1> {};
20 template <typename, template <typename> class> struct aj;
21 template <typename... j, template <typename> class ak> struct aj<ab<j...>, ak> {
22   using e = ab<typename ak<j>::e...>;
23 };
24 template <unsigned long> struct an;
25 struct ao { typedef an<0> ap; };
26 template <typename a, a...> struct aq {};
27 template <typename, typename = ao::ap> struct as;
28 template <typename a, unsigned long... at> struct as<a, an<at...>> { typedef aq<a> ap; };
29 template <typename a, a> using au = typename as<a>::ap;
30 template <long... at> using av = aq<unsigned long, at...>;
31 template <long ar> using aw = au<unsigned long, ar>;
32 struct ay { using e = h<c<false>::d>; };
33 template <typename, template <typename> class, typename...>
34 struct bb : ay::e {};
35 struct bd { using e = av<>; };
36 struct bg { using e = bd::e; };
37 namespace bi {
38 enum bj { bk };
39 struct bo { enum n { bp }; };
40 struct bq { bool br; static const bo::n bs = bo::bp; };
41 template <typename bv> struct bw { using e = bv; };
42 template <typename, bj, int, typename...> class bx;
43 template <typename bv, bj by, int bz, typename... j, long... anchors>
44 struct bx<bv, by, bz, ab<j...>, av<anchors...>> : bo {
45   static const n bs = bv::bs;
46   static const long ca = sizeof bv::br;
47   using cb = int;
48   using cc = ab<j...>;
49   using cd = typename ag<cc, bz>::e;
50   using ce = typename ag<cc, bz>::e;
51   using cf = aw<ca>;
52   using cg = typename bw<bv>::e;
53   using ch = decltype(cg()(cb(), cd(), ce(), cf()));
54 };
55 class ck;
56 template <typename> struct cl : c<false> {};
57 template <typename bv, bj by, int bz, typename... j>
58 struct bx<bv, by, bz, ab<j...>> : public bx<bv, by, bz, typename aj<ab<j...>, cl>::e, bg::e> {};
59 }
60 using bi::bj;
61 using bi::ck;
62 template <typename cn> class co {
63   template <typename p> co(p) { c<cn::bs>(); }
64   static co o;
65 };
66 namespace bi {
67 template <typename> class cp;
68 template <typename j> using cq = bb<j, cp>;
69 template <typename, typename cr> void cs(cr, f<cq<cr>::d, void *> = nullptr);
70 }
71 using bi::cs;
72 struct cu : bi::bq {
73   template <typename... cw, typename... cx>
74   auto operator()(int q, ab<cw...>, ab<cx...>, av<>) {
75     cs<cw...>(q);
76   }
77 };
78 template <>
79 co<bi::bx<cu, bj::bk, 1, ab<int, ck>>>
80 co<bi::bx<cu, bj::bk, 1, ab<int, ck>>>::o(0);
81