1 #ifndef CommonTools_Utils_DynArray_H
2 #define CommonTools_Utils_DynArray_H
18 explicit DynArray(
unsigned char* storage) :
a((
T*)(storage)),
s(0) {}
20 DynArray(
unsigned char* storage,
unsigned int isize) :
a((
T*)(storage)),
s(isize) {
21 for (
auto i = 0U;
i <
s; ++
i)
24 DynArray(
unsigned char* storage,
unsigned int isize,
T const& it) :
a((
T*)(storage)),
s(isize) {
25 for (
auto i = 0U;
i <
s; ++
i)
47 for (
auto i = 0U;
i <
s; ++
i)
59 T const*
end()
const {
return a +
s; }
60 unsigned int size()
const {
return s; }
61 bool empty()
const {
return 0 ==
s; }
65 T const&
back()
const {
return a[
s - 1]; }
84 return s > 0 ? s :
T(1);
88 #define unInitDynArray(T, n, x) \
89 alignas(alignof(T)) unsigned char x##_storage[sizeof(T) * dynarray::num(n)]; \
90 DynArray<T> x(x##_storage)
91 #define declareDynArray(T, n, x) \
92 alignas(alignof(T)) unsigned char x##_storage[sizeof(T) * dynarray::num(n)]; \
93 DynArray<T> x(x##_storage, n)
94 #define initDynArray(T, n, x, i) \
95 alignas(alignof(T)) unsigned char x##_storage[sizeof(T) * dynarray::num(n)]; \
96 DynArray<T> x(x##_storage, n, i)
98 #endif // CommonTools_Utils_DynArray_H
DynArray & operator=(DynArray &&other)
DynArray(DynArray &&other)
T const & const_reference
T const & operator[](unsigned int i) const
DynArray & operator=(DynArray const &)=delete
DynArray(unsigned char *storage, unsigned int isize, T const &it)
DynArray(unsigned char *storage, unsigned int isize)
void push_back(T const &t)
DynArray(unsigned char *storage)
unsigned int size() const
T & operator[](unsigned int i)