| 324 | |
| 325 | template <class T, u64 I> |
| 326 | void sequence<T, I>::reserve(const u64 size) noexcept |
| 327 | { |
| 328 | if(size <= this->capacity_) |
| 329 | return; |
| 330 | byte* allocated_byte = allocator<byte>::allocate_array(size * ELEMENT_SIZE); |
| 331 | T* old_data = this->data(); |
| 332 | const auto source = reinterpret_cast<byte*>(old_data); |
| 333 | if(!this->is_empty()) |
| 334 | { |
| 335 | const auto source_end = reinterpret_cast<byte*>(old_data + this->size_); |
| 336 | std::move(source, source_end, allocated_byte); |
| 337 | } |
| 338 | if(!this->is_short()) |
| 339 | allocator<byte>::deallocate_array(source); |
| 340 | this->as_large().heap_storage = reinterpret_cast<T*>(allocated_byte); |
| 341 | this->capacity_ = size; |
| 342 | } |
| 343 | |
| 344 | template <class T, u64 I> |
| 345 | void sequence<T, I>::push_back_uninitialized(const u64 size) noexcept |