FSF GCC merge 02/23/03
[official-gcc.git] / gcc / testsuite / g++.old-deja / g++.brendan / crash7.C
blob19476fc47ce44e38cd97bf99df4a392f8759d666
1 // Build don't link: 
2 // GROUPS passed templates
4 template<class T>
5 class Vector
7   int sz;
8   T *v;
9 public:
10   Vector (int s) : sz (s) { v = new T[sz]; }
11   ~Vector () { delete[] v; }
12   T &operator[] (int i) { return v[i]; }
13   int size () { return sz; }
16 template<class T>// ERROR - previous definition of T
17 struct Comparator
19   typedef T T;// ERROR - use of template type T in typedef to T
20   static int lessthan (T &a, T &b) { return a < b; }
23 template<class Comp>
24 struct Sort
26   static void sort (Vector<Comp::T> &);// ERROR - use of bad T
29 template<class Comp>
30 void Sort<Comp>::sort (Vector<Comp::T> &v)// ERROR - use of bad T
32   int n = v.size ();
34   for (int i = 0; i < n - 1; i++)
35     for (int j = n - 1; i < j; j--)
36       if (Comp::lessthan (v[j], v[j - 1]))
37         {
38           typename Comp::T temp = v[j];
39           v[j] = v[j - 1];
40           v[j - 1] = temp;
41         }
44 void
45 f (Vector<int> &vi)
47   Sort<Comparator<int> >::sort (vi);