15#ifndef TLX_CONTAINER_SIMPLE_VECTOR_HEADER
16#define TLX_CONTAINER_SIMPLE_VECTOR_HEADER
48template <
typename ValueType,
92 { v.size_ = 0, v.array_ =
nullptr; }
96 if (&v ==
this)
return *
this;
99 v.size_ = 0, v.array_ =
nullptr;
155 return *(
begin() + i);
159 return *(
begin() + i);
199 return static_cast<ValueType*
>(
200 operator new (
size *
sizeof(ValueType)));
214 for (
size_t i = 0; i <
size; ++i)
215 array[i].~ValueType();
216 operator delete (array);
220 operator delete (array);
Simpler non-growing vector without initialization.
static ValueType * create_array(size_t size)
size_type size() const noexcept
return number of items in vector
iterator data() noexcept
return iterator to beginning of vector
const_iterator begin() const noexcept
return constant iterator to first element
void destroy()
deallocate contained array
SimpleVector & operator=(const SimpleVector &)=delete
non-copyable: delete assignment operator
void resize(size_type new_size)
resize the array to contain exactly new_size items
size_type size_
size of allocated memory
value_type * array_
pointer to allocated memory area
SimpleVector()
allocate empty simple vector
const_iterator end() const noexcept
return constant iterator beyond last element
void fill(const value_type &v=value_type()) noexcept
Zero the whole array content.
const_iterator data() const noexcept
return iterator to beginning of vector
iterator begin() noexcept
return mutable iterator to first element
const_iterator cend() const noexcept
return constant iterator beyond last element
SimpleVector(const size_type &sz)
allocate vector's memory
void swap(SimpleVector &obj) noexcept
swap vector with another one
reference operator[](size_type i) noexcept
return the i-th position of the vector
const value_type & const_reference
SimpleVector(SimpleVector &&v) noexcept
move-constructor
const_iterator cbegin() const noexcept
return constant iterator to first element
SimpleVector(const SimpleVector &)=delete
non-copyable: delete copy-constructor
const value_type * const_iterator
~SimpleVector()
delete vector
static void destroy_array(ValueType *array, size_t size)
iterator end() noexcept
return mutable iterator beyond last element
SimpleVectorMode
enum class to select SimpleVector object initialization
@ NoInitNoDestroy
Do not initialize objects at allocation and do not destroy them.
@ Normal
Initialize objects at allocation and destroy on deallocation.
@ NoInitButDestroy
Do not initialize objects at allocation, but destroy on deallocation.
static uint32_t min(uint32_t x, uint32_t y)
void swap(CountingPtr< A, D > &a1, CountingPtr< A, D > &a2) noexcept
swap enclosed object with another counting pointer (no reference counts need change)