6#include <initializer_list>
9#include <memory_resource>
28 template<
typename T,
size_t N>
31 using underlying_vector = std::pmr::vector<T>;
33 using value_type =
typename underlying_vector::value_type;
35 using size_type =
typename underlying_vector::size_type;
37 using reference =
typename underlying_vector::reference;
39 using pointer =
typename underlying_vector::pointer;
41 using iterator =
typename underlying_vector::iterator;
53 requires std::copy_constructible<T> :
54 pool{stack_data_.data(), stack_data_.size(),
other.pool.upstream_resource()}
57 vector_.assign(
other.vector_.begin(),
other.vector_.end());
61 requires std::move_constructible<T> :
62 pool{stack_data_.data(), stack_data_.size(),
other.pool.upstream_resource()}
65 vector_.assign(std::make_move_iterator(
other.vector_.begin()), std::make_move_iterator(
other.vector_.end()));
69 std::initializer_list<T> init,
75 vector_.assign(init.begin(), init.end());
79 requires std::is_copy_assignable_v<T>
86 requires std::is_move_assignable_v<T>
88 vector_.assign(std::make_move_iterator(
other.vector_.begin()), std::make_move_iterator(
other.vector_.end()));
117 void push_back(
T&& value) { vector_.push_back(std::move(value)); }
128#if defined(_MSC_VER) && _ITERATOR_DEBUG_LEVEL > 0
129 static inline constexpr size_t extra_bytes_ = []()
132 constexpr size_t proxy_size =
sizeof(std::_Container_proxy);
139 static inline constexpr size_t extra_bytes_ = 0;
143 alignas(
T) std::array<std::byte,
N *
sizeof(
T) + extra_bytes_> stack_data_;
146 std::pmr::monotonic_buffer_resource pool{stack_data_.data(), stack_data_.size(), std::pmr::new_delete_resource()};
149 underlying_vector vector_ = underlying_vector(&pool);
Definition variable_length_array.h:29
void push_back(const T &value)
Definition variable_length_array.h:116
VariableLengthArray(VariableLengthArray &&other) noexcept
Definition variable_length_array.h:60
const_iterator cend() const noexcept
Definition variable_length_array.h:103
const_reference front() const
Definition variable_length_array.h:96
void push_back(T &&value)
Definition variable_length_array.h:117
VariableLengthArray(std::initializer_list< T > init, std::pmr::memory_resource *upstream_allocator=std::pmr::new_delete_resource())
Definition variable_length_array.h:68
typename underlying_vector::pointer pointer
Definition variable_length_array.h:39
typename underlying_vector::reference reference
Definition variable_length_array.h:37
const_reference operator[](size_type pos) const
Definition variable_length_array.h:93
size_type size() const noexcept
Definition variable_length_array.h:112
void clear()
Definition variable_length_array.h:114
const_reverse_iterator rbegin() const noexcept
Definition variable_length_array.h:105
typename underlying_vector::size_type size_type
Definition variable_length_array.h:35
typename underlying_vector::iterator iterator
Definition variable_length_array.h:41
friend bool operator==(const VariableLengthArray &lhs, const VariableLengthArray &rhs)
Definition variable_length_array.h:119
typename underlying_vector::difference_type difference_type
Definition variable_length_array.h:36
reference operator[](size_type pos)
Definition variable_length_array.h:92
typename underlying_vector::allocator_type allocator_type
Definition variable_length_array.h:34
iterator end() noexcept
Definition variable_length_array.h:101
const_reverse_iterator crbegin() const noexcept
Definition variable_length_array.h:106
typename underlying_vector::const_reference const_reference
Definition variable_length_array.h:38
const_reverse_iterator rend() const noexcept
Definition variable_length_array.h:108
const_iterator begin() const noexcept
Definition variable_length_array.h:99
const_iterator cbegin() const noexcept
Definition variable_length_array.h:100
reverse_iterator rend() noexcept
Definition variable_length_array.h:107
VariableLengthArray & operator=(const VariableLengthArray &other)
Definition variable_length_array.h:78
const_reverse_iterator crend() const noexcept
Definition variable_length_array.h:109
typename underlying_vector::reverse_iterator reverse_iterator
Definition variable_length_array.h:43
VariableLengthArray(std::pmr::memory_resource *upstream_allocator=std::pmr::new_delete_resource())
Definition variable_length_array.h:46
typename underlying_vector::const_pointer const_pointer
Definition variable_length_array.h:40
iterator begin() noexcept
Definition variable_length_array.h:98
bool empty() const noexcept
Definition variable_length_array.h:111
VariableLengthArray & operator=(VariableLengthArray &&other) noexcept
Definition variable_length_array.h:85
VariableLengthArray(const VariableLengthArray &other)
Definition variable_length_array.h:52
typename underlying_vector::value_type value_type
Definition variable_length_array.h:33
reverse_iterator rbegin() noexcept
Definition variable_length_array.h:104
typename underlying_vector::const_iterator const_iterator
Definition variable_length_array.h:42
const_iterator end() const noexcept
Definition variable_length_array.h:102
reference front()
Definition variable_length_array.h:95
typename underlying_vector::const_reverse_iterator const_reverse_iterator
Definition variable_length_array.h:44
Definition custom_decoration_generator.h:5
constexpr U to(T &&value)
Definition conversion.h:56