Douglas Gregor | 199d991 | 2009-06-05 00:53:49 +0000 | [diff] [blame^] | 1 | // RUN: clang-cc -fsyntax-only -ftemplate-depth=1000 -verify %s |
| 2 | |
| 3 | // template<unsigned M, unsigned N> |
| 4 | // struct Ackermann { |
| 5 | // enum { |
| 6 | // value = M ? (N ? Ackermann<M-1, Ackermann<M-1, 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, 8>::value == 2045 ? 1 : -1]; |