1 #ifndef __auto_array_H__
2 #define __auto_array_H__
3 
4 // like auto_ptr, is an array of pointers of the type that will get freed at destruction
5 #include <vector>
6 
7 namespace std {
8 
9 template<typename T> class auto_array : public vector<T *>
10 {
11 public:
auto_array(unsigned n_elements)12 	auto_array(unsigned n_elements)
13 	{
14 		for(unsigned t=0;t<n_elements;t++)
15 			this->push_back((T *)NULL);
16 	}
17 
~auto_array()18 	virtual ~auto_array()
19 	{
20 		for(unsigned t=0;t<this->size();t++)
21 			delete this->operator[](t);
22 	}
23 
24 };
25 
26 /*
27 template<typename T> class auto_array
28 {
29 public:
30 	auto_array(unsigned n_elements)
31 	{
32 		for(unsigned t=0;t<n_elements;t++)
33 			v.push_back(NULL);
34 	}
35 
36 	virtual ~auto_array()
37 	{
38 		for(unsigned t=0;t<v.size();t++)
39 			delete v[t];
40 	}
41 
42 	T * operator[](unsigned index) const
43 	{
44 		return v[index];
45 	}
46 
47 private:
48 	vector<T *> v;
49 };
50 */
51 
52 };
53 
54 
55 #endif
56