38 template<
class T,
class _Size =
int>
61 operator T* (void) {
return data; }
71 void clear (
bool dealloc =
false);
97 template<
class T,
class _Size>
99 if (cap >= min_cap)
return;
100 Size add = max((min_cap - cap + 1) & ~1, ((cap >> 1) + 2) & ~1);
101 const Size size_max = std::numeric_limits<Size>::max();
102 if ( ((size_max <= std::numeric_limits<int>::max()) && (add > size_max - cap))
103 || (((data = (T*)::realloc(data, (cap += add) *
sizeof(T))) ==
NULL) && errno == ENOMEM) )
108 template<
class T,
class _Size>
110 if (sz >= size)
return;
112 for (
Size i = sz; i < size; i++) data[i] = pad;
116 template<
class T,
class _Size>
118 if (sz >= size)
return;
120 for (
Size i = sz; i < size; i++)
new (&data[i]) T();
124 template<
class T,
class _Size>
127 for (
Size i = 0; i < sz; i++) data[i].~T();
129 if (dealloc)
free(data), data =
NULL, cap = 0; } }
static void copy(const T &from, T &to)
void copyTo(vec< T > ©) const
void shrink_(Size nelems)
const T & last(void) const
static Size max(Size x, Size y)
vec< T > & operator=(vec< T > &other)
vec(Size size, const T &pad)
void clear(bool dealloc=false)
void push_(const T &elem)
void moveTo(vec< T > &dest)
const T & operator[](Size index) const