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 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65
|
template<typename T> class vector_base
{
protected:
T* begin_, last_, end_;
public:
~vector_base() { delete_(begin_, last_); /* detruit de begin_ a last_ */ }
// ...
};
template<typename T> class vector_deleting : private vector_base<T>
{
public:
using vector_base; // Pas sur
void clear()
{
while(last_ != begin_)
{
--last_;
delete last_;
}
delete begin_; // OU delete last_
}
};
template<typename T> class vector_not_deleting : private vector_base<T>
{
public:
using vector_base; // Pas sur
void clear()
{
last_ = begin_;
}
};
template<typename T> class vector : private vector_deleting
{
public:
using vector_deleting; // Pas sur ...
};
class vector<short> : private vector_not_deleting
{
public:
using vector_not_deleting; // Pas sur ...
};
class vector<unsigned short> : private vector_not_deleting
{
public:
using vector_not_deleting; // Pas sur ...
};
class vector<int> : private vector_not_deleting
{
public:
using vector_not_deleting; // Pas sur ...
};
class vector<unsigned int> : private vector_not_deleting
{
public:
using vector_not_deleting; // Pas sur ...
};
class vector<long> : private vector_not_deleting
{
public:
using vector_not_deleting; // Pas sur ...
};
// ... |