22 template <
class T,
unsigned N=0>
43 unsigned size()
const {
return N;}
44 void resize(
unsigned n) { (void) n; }
47 void copy(Array<T,N>
const& other)
49 for (
unsigned i=0; i < N; ++i)
50 elems[i] = other.elems[i];
62 Array(
unsigned n) : sz(0), elems(0) {resize(n);}
78 unsigned size()
const {
return sz;}
88 void resize_copy(
unsigned n)
93 unsigned min = sz > n ? n : sz;
94 for(
unsigned int x = 0; x < min; x++)
101 typedef T
const* const_iterator;
102 T
const* begin()
const {
return elems;}
103 T
const* end()
const {
return elems + sz;}
104 T* begin() {
return elems;}
105 T* end() {
return elems + sz;}
109 void copy(Array<T,0>
const& other)
113 for (
unsigned i = 0; i < sz; ++i)
114 elems[i] = other.elems[i];
Array< T, 0 > & operator=(Array< T, 0 > const &other)
assignment operator
T & operator[](unsigned i)
mutable index operator
T const & operator[](unsigned i) const
immutable index operator
T const & operator[](unsigned i) const
immutable index operator
Array()
default constructor - necessary
~Array()
destructor - need to delete elems
Array(Array< T, N > const &other)
copy constructor
Array(unsigned n)
construct with n elems
~Array()
elems is destroyed automatically
compile-time (static) array of size N
Array()
default constructor - no allocation
T & operator[](unsigned i)
mutable index operator
unsigned size() const
get the size of this array
Array(Array< T, 0 > const &other)
copy constructor
unsigned size() const
get the size of this array
void resize(unsigned n)
resize the array
Array< T, N > & operator=(Array< T, N > const &other)
assignment operator