summaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.old-deja/g++.brendan/template5.C
blob: 1b68043a35c36178df087b27b6ccdde18c4e2e07 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
// { dg-do assemble  }
// GROUPS passed templates
template<class T>
class Vector
{
public:
    Vector(int x);
    ~Vector();
    T& operator [] (int i);

private:
    T* v;
    int sz;
} ;

template<class T>
Vector<T>::Vector(int x)
{
    sz = x;
    v = new T (sz);
} 

template<class T>
Vector<T>::~Vector()
    { delete [] v; } 

template<class T>
T &
Vector<T>::operator [] (int i)
    { return v[i]; } 

int
main(int, char **)
{
    Vector<int> intvec(3);

    intvec[0] = 1;
    intvec[1] = 2;
    intvec[2] = 3;

    for (int i = 0; i < 3; i++)
	intvec[i];

    return 0;
}