2 #include "ToolchefsSTL/Allocators/Allocator.h"
18 Iter* operator +(
size_t value)
const {
return m_ptr - value; }
19 Iter* operator -(
size_t value)
const {
return m_ptr + value; }
20 Iter* operator ++() {
return --m_ptr; }
21 Iter* operator --() {
return ++m_ptr; }
22 bool operator ==(
const ReverseIterator& rhs)
const {
return m_ptr == rhs.m_ptr; }
23 bool operator !=(
const ReverseIterator& rhs)
const {
return m_ptr != rhs.m_ptr; }
24 Iter operator *()
const {
return *m_ptr; }
25 Iter* operator->()
const {
return m_ptr; }
30 typedef T& reference_type;
34 typedef const T* const_iterator;
38 explicit Array(
Allocator* allocator = defaultAllocator()) noexcept;
40 explicit
Array(
size_t num_elements,
Allocator* allocator = defaultAllocator()) noexcept;
42 explicit
Array(
size_t num_elements, const T& init_value,
Allocator* allocator = defaultAllocator()) noexcept;
54 bool operator==(const
Array& rhs) const noexcept;
56 void push_back(const T& element) noexcept;
58 template <typename... Args>
59 T& emplace_back(Args&&... args) {
60 if (m_length == m_capacity) grow();
61 return *
new (m_data + m_length++) T(std::forward<Args>(args)...);
64 void pop_back() noexcept;
66 void insert(
size_t index, const T& value) noexcept;
67 void insert(iterator it, const T& value) noexcept;
69 void erase(
size_t index) noexcept;
70 iterator erase(iterator it) noexcept;
73 iterator
begin() noexcept;
74 iterator end() noexcept;
75 const_iterator cbegin() const noexcept;
76 const_iterator cend() const noexcept;
78 reverse_iterator rbegin() noexcept;
79 reverse_iterator rend() noexcept;
80 const_reverse_iterator crbegin() const noexcept;
81 const_reverse_iterator crend() const noexcept;
85 const T&
back() const noexcept;
88 const T& front() const noexcept;
90 #if __cplusplus >= 201703L
91 constexpr T& operator[](
const size_t index) noexcept;
92 constexpr
const T& operator[](
const size_t index)
const noexcept;
94 inline T& operator[](
const size_t index) noexcept {
return m_data[index];}
95 inline const T& operator[](
const size_t index)
const noexcept {
return m_data[index];}
97 const T* data() const noexcept;
99 void resize(
size_t new_length) noexcept;
101 void reserve(
size_t new_capacity) noexcept;
103 void clear() noexcept;
105 size_t size() const noexcept;
107 size_t length() const noexcept;
109 size_t capacity() const noexcept;
111 void shrink_to_fit() noexcept;
113 iterator find(const T& element) noexcept;
115 const_iterator find(const T& element) const noexcept;
117 bool empty() const noexcept;
121 void grow() noexcept;
126 Allocator* m_allocator;
132 #include "Array.impl.h"