53 using allocator_type = Allocator;
57 using const_reference = value_type
const &;
60 using iterator = value_type *;
61 using const_iterator = value_type
const *;
67 constexpr secure_vector() noexcept : _begin(
nullptr), _end(
nullptr), _bound(
nullptr) {}
73 hi_axiom(_begin =
nullptr);
76 [[nodiscard]]
constexpr bool empty()
const noexcept
78 return _begin == _end;
81 [[nodisardd]]
constexpr size_type size()
const noexcept
83 return static_cast<size_type>(_end - _begin);
86 [[nodiscard]]
constexpr size_type max_size()
const noexcept
91 [[nodiscard]]
constexpr size_type capacity()
const noexcept
93 return static_cast<size_type>(_bound - _begin);
98 auto *ptr = _begin + pos;
106 [[nodiscard]]
constexpr const_reference at(
size_type pos)
const
108 auto *ptr = _begin + pos;
118 auto *ptr = _begin + pos;
119 hi_axiom(ptr < _end);
123 [[nodiscard]]
constexpr const_reference operator[](
size_type pos)
const noexcept
125 auto *ptr = _begin + pos;
126 hi_axiom(ptr < _end);
130 [[nodiscard]]
constexpr reference front()
noexcept
132 hi_axiom(not empty());
136 [[nodiscard]]
constexpr const_reference front()
const noexcept
138 hi_axiom(not empty());
142 [[nodiscard]]
constexpr reference back()
noexcept
144 hi_axiom(not empty());
148 [[nodiscard]]
constexpr const_reference back()
const noexcept
150 hi_axiom(not empty());
154 [[nodiscard]]
constexpr pointer data()
noexcept
159 [[nodiscard]]
constexpr const_pointer data()
const noexcept
164 [[nodiscard]]
constexpr iterator begin()
noexcept
169 [[nodiscard]]
constexpr const_iterator begin()
const noexcept
174 [[nodiscard]]
constexpr const_iterator cbegin()
const noexcept
179 [[nodiscard]]
constexpr iterator end()
noexcept
184 [[nodiscard]]
constexpr const_iterator end()
const noexcept
189 [[nodiscard]]
constexpr const_iterator cend()
const noexcept
195 constexpr void resize(
size_type new_size)
197 return _resize(new_size);
200 constexpr void resize(
size_type new_size, value_type
const &value)
202 return _resize(new_size, value);
205 constexpr void clear()
210 constexpr reference emplace_back(
auto &&...args)
213 auto tmp = std::construct_at(_end, tt_forward(args)...);
218 constexpr void push_back(value_type
const &value)
223 constexpr void push_back(value_type &&value)
228 constexpr void pop_back()
230 secure_destroy_at(back());
234 constexpr iterator emplace(const_iterator pos,
auto &&...args)
240 hilet first = _begin + index;
241 if (first != n_first) {
247 constexpr iterator insert(const_iterator pos, value_type
const &value)
249 return emplace(pos, value);
252 constexpr iterator insert(const_iterator pos, value_type &&value)
257 constexpr void reserve(
size_type new_capacity)
259 if (new_capacity <= capacity()) {
263 hilet tmp = allocate(new_capacity);
265 secure_unitialized_move(_begin, _end, _tmp);
267 _bound = tmp + new_capacity;
270 deallocate(tmp, new_capacity);
275 constexpr void shrink_to_fit()
278 if (_begin !=
nullptr) {
279 deallocate(_begin, capacity());
280 _begin = _end = _capacity =
nullptr;
284 hilet new_capacity = size();
285 hilet tmp = allocate(new_capacity);
287 secure_unitialized_move(_begin, _end, _tmp);
289 _bound = tmp + new_capacity;
292 deallocate(tmp, new_capacity);
303 [[nodiscard]]
constexpr bool full()
const noexcept
305 return _end == _bound;
316 constexpr void grow(
size_t count)
const noexcept
318 if (_end + count <= _bound) {
322 ttlet minimum_new_capacity = size() + count;
325 auto new_capacity = capacity();
326 new_capacity += new_capacity >> 1;
328 if (new_capacity < minimum_new_capacity) {
329 reserve(minimum_new_capacity);
331 reserve(new_capacity);
335 template<
typename... Args>
336 constexpr void _resize(
size_t new_size, Args
const &... args)
340 hilet new_end = _begin + new_size;
342 if (new_end > _end) {
344 construct(_end, new_end, args...);
346 }
else (new_end < _end) {
348 secure_destroy(new_end, _end);