1 /* { dg-do compile } */
2 /* { dg-options "-O2" } */
3 /* { dg-additional-options "-Wno-return-type" } */
4
5 namespace Gambit
6 {
7 template < class T > class Array
8 {
9 protected:int mindex, maxdex;
10 T *data;
InsertAt(const T & t,int n)11 int InsertAt (const T & t, int n)
12 {
13 T *new_data = new T[++this->maxdex - this->mindex + 1] - this->mindex;
14 int i;
15 for (i = this->mindex; i <= n - 1; i++)
16 new_data[i] = this->data[i];
17 }
18 public: Array (unsigned int len = 0):mindex (1), maxdex (len),
19 data ((len) ? new T[len] -
20 1 : 0)
21 {
22 }
~Array()23 virtual ~ Array ()
24 {
25 if (maxdex >= mindex)
26 delete[](data + mindex);
27 }
28 const T & operator[] (int index) const
29 {
30 }
Append(const T & t)31 int Append (const T & t)
32 {
33 return InsertAt (t, this->maxdex + 1);
34 }
35 };
36 }
37 class gIndexOdometer
38 {
39 private:Gambit::Array < int >MinIndices;
40 Gambit::Array < int >CurIndices;
41 gIndexOdometer (const Gambit::Array < int >, const Gambit::Array < int >);
42 void SetIndex (const int &, const int &);
43 int NoIndices () const;
44 gIndexOdometer AfterExcisionOf (int &) const;
45 };
46 gIndexOdometer
AfterExcisionOf(int & to_be_zapped)47 gIndexOdometer::AfterExcisionOf (int &to_be_zapped) const
48 {
49 Gambit::Array < int >NewMins, NewMaxs;
50 int i;
51 for (i = 1; i <= NoIndices (); i++)
52 {
53 NewMins.Append (MinIndices[i]);
54 }
55 gIndexOdometer NewOdo (NewMins, NewMaxs);
56 NewOdo.SetIndex (i, CurIndices[i]);
57 }
58
59