1 // RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
2 // expected-no-diagnostics
3 
4 template<template<template<typename> class, typename> class T, template<typename> class V> struct PartialApply {
5   template<typename W> using R = T<V, W>;
6 };
7 
8 template<typename T> using Id = T;
9 template<template<typename> class, typename X> using Zero = X;
10 template<template<template<typename> class, typename> class N, template<typename> class F, typename X> using Succ = F<N<F,X>>;
11 
12 template<template<typename> class F, typename X> using One = Succ<Zero, F, X>;
13 template<template<typename> class F, typename X> using Two = Succ<One, F, X>;
14 
15 template<template<template<typename> class, typename> class A,
16          template<template<typename> class, typename> class B,
17          template<typename> class F,
18          typename X> using Add = A<F, B<F, X>>;
19 
20 template<template<template<typename> class, typename> class A,
21          template<template<typename> class, typename> class B,
22          template<typename> class F,
23          typename X> using Mul = A<PartialApply<B,F>::template R, X>;
24 
25 template<template<typename> class F, typename X> using Four = Add<Two, Two, F, X>;
26 template<template<typename> class F, typename X> using Sixteen = Mul<Four, Four, F, X>;
27 template<template<typename> class F, typename X> using TwoHundredAndFiftySix = Mul<Sixteen, Sixteen, F, X>;
28 
29 template<typename T, T N> struct Const { static const T value = N; };
30 template<typename A> struct IncrementHelper;
31 template<typename T, T N> struct IncrementHelper<Const<T, N>> { using Result = Const<T, N+1>; };
32 template<typename A> using Increment = typename IncrementHelper<A>::Result;
33 
34 using Arr = int[TwoHundredAndFiftySix<Increment, Const<int, 0>>::value];
35 using Arr = int[256];
36