gcc/testsuite/g++.old-deja/g++.pt/parms1.C
raw| 1 | // { dg-do run } |
| 2 | // Testcase for use of template parms as types for other template parms. |
| 3 | |
| 4 | template <class T, T t> |
| 5 | class A { |
| 6 | T a; |
| 7 | public: |
| 8 | A(): a(t) {} |
| 9 | |
| 10 | operator T () { return a; } |
| 11 | }; |
| 12 | |
| 13 | template <class S, S s> |
| 14 | class B { |
| 15 | A<S,s> a; |
| 16 | public: |
| 17 | B(A<S,s>& b): a(b) {} |
| 18 | |
| 19 | operator S () { return a*20; } |
| 20 | }; |
| 21 | |
| 22 | int |
| 23 | main() |
| 24 | { |
| 25 | A<int, 5> a; |
| 26 | B<int, 5> b(a); |
| 27 | |
| 28 | if (b * a == 500) |
| 29 | return 0; |
| 30 | else |
| 31 | return 1; |
| 32 | } |