• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // RUN: %clang_cc1 -fsyntax-only -verify %s
2 
3 // template<unsigned M, unsigned N>
4 // struct Ackermann {
5 //   enum {
6 //     value = M ? (N ? Ackermann<M-1, Ackermann<M, N-1> >::value
7 //                    : Ackermann<M-1, 1>::value)
8 //               : N + 1
9 //   };
10 // };
11 
12 template<unsigned M, unsigned N>
13 struct Ackermann {
14  enum {
15    value = Ackermann<M-1, Ackermann<M, N-1>::value >::value
16  };
17 };
18 
19 template<unsigned M> struct Ackermann<M, 0> {
20  enum {
21    value = Ackermann<M-1, 1>::value
22  };
23 };
24 
25 template<unsigned N> struct Ackermann<0, N> {
26  enum {
27    value = N + 1
28  };
29 };
30 
31 template<> struct Ackermann<0, 0> {
32  enum {
33    value = 1
34  };
35 };
36 
37 int g0[Ackermann<3, 4>::value == 125 ? 1 : -1];
38 
39