#include "cetl/variable_length_array.hpp"
Classes | |
| class | reference |
Public Types | |
| using | value_type = bool |
| using | difference_type = typename base::difference_type |
| using | size_type = typename base::size_type |
| using | allocator_type = typename base::allocator_type |
| using | const_reference = bool |
| using | iterator = iterator_impl<variable_length_array> |
| using | const_iterator = iterator_impl<const variable_length_array> |
| using | reverse_iterator = std::reverse_iterator<iterator> |
| using | const_reverse_iterator = std::reverse_iterator<const_iterator> |
| using | value_type |
| using | pointer |
| using | iterator |
| using | const_iterator |
| using | reverse_iterator |
| using | const_reverse_iterator |
| using | difference_type |
| using | size_type |
| using | allocator_type |
| using | reference |
| using | const_reference |
Public Member Functions | |
| constexpr | variable_length_array (size_type max_size_max, const allocator_type &alloc) noexcept |
| constexpr | variable_length_array (const allocator_type &alloc) noexcept |
| variable_length_array (std::initializer_list< bool > l, size_type max_size_max, const allocator_type &alloc) | |
| variable_length_array (std::initializer_list< bool > l, const allocator_type &alloc) | |
| template<typename Count, typename = detail::enable_if_count_t<Count, size_type>> | |
| variable_length_array (Count count, const bool value, size_type max_size_max, const allocator_type &alloc) | |
| template<typename Count, typename = detail::enable_if_count_t<Count, size_type>> | |
| variable_length_array (Count count, const bool value, const allocator_type &alloc) | |
| template<class InputIt, typename = detail::enable_if_input_iterator_t<InputIt>> | |
| variable_length_array (InputIt first, InputIt last, size_type max_size_max, const allocator_type &alloc) | |
| template<class InputIt, typename = detail::enable_if_input_iterator_t<InputIt>> | |
| variable_length_array (InputIt first, InputIt last, const allocator_type &alloc) | |
| variable_length_array (const variable_length_array &rhs, const allocator_type &alloc) | |
| variable_length_array (const variable_length_array &rhs) | |
| variable_length_array & | operator= (const variable_length_array &rhs) |
| variable_length_array (variable_length_array &&rhs) noexcept | |
| variable_length_array (variable_length_array &&rhs, const allocator_type &alloc) noexcept(std::allocator_traits< allocator_type >::is_always_equal::value) | |
| variable_length_array & | operator= (variable_length_array &&rhs) noexcept(std::allocator_traits< allocator_type >::propagate_on_container_move_assignment::value||std::allocator_traits< allocator_type >::is_always_equal::value) |
| variable_length_array & | operator= (std::initializer_list< bool > values) |
| constexpr bool | operator== (const variable_length_array &rhs) const noexcept |
| constexpr bool | operator!= (const variable_length_array &rhs) const noexcept |
| constexpr bool | operator< (const variable_length_array &rhs) const noexcept |
| constexpr bool | operator> (const variable_length_array &rhs) const noexcept |
| constexpr bool | operator<= (const variable_length_array &rhs) const noexcept |
| constexpr bool | operator>= (const variable_length_array &rhs) const noexcept |
| constexpr const_iterator | cbegin () const noexcept |
| constexpr const_iterator | cend () const noexcept |
| constexpr iterator | begin () noexcept |
| constexpr iterator | end () noexcept |
| constexpr const_iterator | begin () const noexcept |
| constexpr const_iterator | end () const noexcept |
| constexpr reverse_iterator | rbegin () noexcept |
| constexpr const_reverse_iterator | rbegin () const noexcept |
| constexpr const_reverse_iterator | crbegin () const noexcept |
| constexpr reverse_iterator | rend () noexcept |
| constexpr const_reverse_iterator | rend () const noexcept |
| constexpr const_reverse_iterator | crend () const noexcept |
| constexpr const_reference | operator[] (const size_type pos) const noexcept |
| constexpr reference | operator[] (const size_type pos) noexcept |
| constexpr allocator_type | get_allocator () const noexcept |
| constexpr reference | at (size_type pos) |
| constexpr const_reference | at (size_type pos) const |
| constexpr reference | front () |
| constexpr const_reference | front () const |
| constexpr reference | back () |
| constexpr const_reference | back () const |
| constexpr bool | empty () const noexcept |
| constexpr size_type | max_size () const noexcept |
| void | shrink_to_fit () |
| constexpr size_type | capacity () const noexcept |
| constexpr size_type | size () const noexcept |
| void | reserve (const size_type desired_capacity) |
| constexpr void | clear () noexcept |
| constexpr void | push_back (bool value) |
| constexpr void | pop_back () noexcept |
| iterator | erase (const_iterator pos) noexcept |
| iterator | erase (const_iterator first, const_iterator last) noexcept |
| iterator | insert (const_iterator pos, const bool value) |
| iterator | insert (const_iterator pos, const size_type count, const bool value) |
| template<typename InputIt, typename = detail::enable_if_input_iterator_t<InputIt>> | |
| iterator | insert (const_iterator pos, InputIt first, InputIt last) |
| iterator | insert (const_iterator pos, std::initializer_list< bool > values) |
| void | emplace_back (bool value) |
| constexpr void | resize (size_type count) |
| constexpr void | resize (size_type count, const bool value) |
| constexpr void | assign (size_type count, const bool &value) |
| template<typename InputIt, typename = detail::enable_if_input_iterator_t<InputIt>> | |
| void | assign (InputIt first, InputIt last) |
| void | assign (std::initializer_list< bool > values) |
| variable_length_array (const allocator_type &alloc) noexcept | |
| variable_length_array (size_type max_size_max, const allocator_type &alloc) noexcept | |
| variable_length_array (std::initializer_list< value_type > l, size_type max_size_max, const allocator_type &alloc) | |
| variable_length_array (std::initializer_list< value_type > l, const allocator_type &alloc) | |
| variable_length_array (Count count, const value_type &value, size_type max_size_max, const allocator_type &alloc) | |
| variable_length_array (Count count, const value_type &value, const allocator_type &alloc) | |
| variable_length_array (InputIt first, InputIt last, size_type max_size_max, const allocator_type &alloc) | |
| variable_length_array (InputIt first, InputIt last, const allocator_type &alloc) | |
| variable_length_array (const variable_length_array &rhs, const allocator_type &alloc) | |
| variable_length_array (const variable_length_array &rhs) | |
| variable_length_array (variable_length_array &&rhs, const allocator_type &alloc) noexcept(std::allocator_traits< allocator_type >::is_always_equal::value) | |
| variable_length_array (variable_length_array &&rhs) noexcept | |
| variable_length_array & | operator= (const variable_length_array &rhs) |
| variable_length_array & | operator= (variable_length_array &&rhs) noexcept(std::allocator_traits< allocator_type >::propagate_on_container_move_assignment::value||std::allocator_traits< allocator_type >::is_always_equal::value) |
| variable_length_array & | operator= (std::initializer_list< value_type > values) |
| constexpr bool | operator== (const variable_length_array &rhs) const noexcept |
| constexpr bool | operator!= (const variable_length_array &rhs) const noexcept |
| constexpr bool | operator< (const variable_length_array &rhs) const |
| constexpr bool | operator> (const variable_length_array &rhs) const |
| constexpr bool | operator<= (const variable_length_array &rhs) const |
| constexpr bool | operator>= (const variable_length_array &rhs) const |
| constexpr const_iterator | cbegin () const noexcept |
| constexpr const_iterator | cend () const noexcept |
| constexpr iterator | begin () noexcept |
| constexpr const_iterator | begin () const noexcept |
| constexpr iterator | end () noexcept |
| constexpr const_iterator | end () const noexcept |
| constexpr reverse_iterator | rbegin () noexcept |
| constexpr const_reverse_iterator | rbegin () const noexcept |
| constexpr const_reverse_iterator | crbegin () const noexcept |
| constexpr reverse_iterator | rend () noexcept |
| constexpr const_reverse_iterator | rend () const noexcept |
| constexpr const_reverse_iterator | crend () const noexcept |
| constexpr value_type * | data () noexcept |
| constexpr const value_type * | data () const noexcept |
| constexpr const value_type & | operator[] (size_type pos) const noexcept |
| constexpr value_type & | operator[] (size_type pos) noexcept |
| constexpr allocator_type | get_allocator () const noexcept |
| constexpr reference | at (size_type pos) |
| constexpr const_reference | at (size_type pos) const |
| constexpr reference | front () |
| constexpr const_reference | front () const |
| constexpr reference | back () |
| constexpr const_reference | back () const |
| constexpr bool | empty () const noexcept |
| void | shrink_to_fit () |
| constexpr size_type | capacity () const noexcept |
| constexpr size_type | size () const noexcept |
| void | reserve (const size_type desired_capacity) |
| constexpr size_type | max_size () const noexcept |
| constexpr void | clear () noexcept(std::is_nothrow_destructible< value_type >::value) |
| constexpr void | push_back (const value_type &value) |
| constexpr void | push_back (value_type &&value) |
| constexpr void | pop_back () noexcept(std::is_nothrow_destructible< value_type >::value) |
| iterator | erase (const_iterator pos) noexcept(std::is_nothrow_move_assignable< value_type >::value &&std::is_nothrow_destructible< value_type >::value) |
| iterator | erase (const_iterator first, const_iterator last) noexcept(std::is_nothrow_move_assignable< value_type >::value &&std::is_nothrow_destructible< value_type >::value) |
| iterator | insert (const_iterator pos, const value_type &value) |
| iterator | insert (const_iterator pos, value_type &&value) |
| iterator | insert (const_iterator pos, const size_type count, const value_type &value) |
| iterator | insert (const_iterator pos, InputIt first, InputIt last) |
| iterator | insert (const_iterator pos, std::initializer_list< value_type > values) |
| void | emplace_back (Args &&... args) |
| constexpr void | resize (size_type count) |
| constexpr void | resize (size_type count, const value_type &value) |
| constexpr void | assign (size_type count, const value_type &value) |
| void | assign (InputIt first, InputIt last) |
| void | assign (std::initializer_list< value_type > values) |
Static Public Member Functions | |
| static constexpr bool | test (const variable_length_array &container, const size_type pos) noexcept |
| static constexpr void | set (variable_length_array &container, const size_type pos, const bool value=true) noexcept |
| static void | swap (reference lhs, reference rhs) noexcept |
Protected Types | |
| using | storage = unsigned char |
| using | base = detail::variable_length_array_base<storage, Allocator> |
| using | base |
A memory-optimized specialization for bool storing 8 bits per byte.
The internal bit ordering is little-endian.
| Allocator | The allocator type to use. |
| using cetl::variable_length_array< bool, Allocator >::allocator_type |
Per the std::uses_allocator protocol.
| using cetl::variable_length_array< bool, Allocator >::const_iterator |
STL-like declaration of the const iterator type.
| using cetl::variable_length_array< bool, Allocator >::const_reference |
STL-like declaration of constant-reference type.
| using cetl::variable_length_array< bool, Allocator >::const_reverse_iterator |
STL-like declaration of the const reverse iterator type.
| using cetl::variable_length_array< bool, Allocator >::difference_type |
STL-like declaration of the container's difference type.
| using cetl::variable_length_array< bool, Allocator >::iterator |
STL-like declaration of the iterator type.
| using cetl::variable_length_array< bool, Allocator >::pointer |
STL-like declaration of pointer type.
| using cetl::variable_length_array< bool, Allocator >::reference |
STL-like declaration of reference type.
| using cetl::variable_length_array< bool, Allocator >::reverse_iterator |
STL-like declaration of the reverse iterator type.
| using cetl::variable_length_array< bool, Allocator >::size_type |
STL-like declaration of the container's size type.
| using cetl::variable_length_array< bool, Allocator >::value_type |
STL-like declaration of the container's storage type.
|
inlineexplicitconstexprnoexcept |
Required constructor for std::uses_allocator protocol with maximum max size.
| max_size_max | Clamping value for the maximum size of this array. That is, std::min(max_size_max, std::allocator_traits<allocator_type>::max_size(alloc)) cetl::variable_length_array::max_size() will return |
| alloc | Allocator to use for all allocations. |
Referenced by operator<(), operator<=(), operator=(), operator>(), operator>=(), set(), test(), variable_length_array(), variable_length_array(), variable_length_array(), and variable_length_array().

|
inlineexplicitconstexprnoexcept |
Required constructor for std::uses_allocator protocol.
| alloc | Allocator to use for all allocations. |
References variable_length_array().
|
inline |
Initializer syntax constructor with maximum max size.
| l | Initializer list of elements to copy into the array. |
| max_size_max | Clamping value for the maximum size of this array. That is, cetl::variable_length_array::max_size() will return std::min(max_size_max, std::allocator_traits<allocator_type>::max_size(alloc)) |
| alloc | Allocator to use for all allocations. |
References emplace_back(), max_size(), and std::initializer_list::size().
|
inline |
Initializer syntax constructor.
| l | Initializer list of elements to copy into the array. |
| alloc | Allocator to use for all allocations. |
References variable_length_array().
|
inline |
Count-value constructor with maximum max size.
Constructs count copies of value, as std::vector<bool>(count, value, alloc) does, allocating the bytes needed for exactly count bits. The count may be any type that converts to size_type, but not a braced list: variable_length_array({x}, n, alloc) selects the initializer-list constructor. There is no (count, alloc) overload, because variable_length_array(n, alloc) sets max_size_max. With exceptions disabled, the array is truncated to max_size() or to the storage the allocator provides, which the caller can detect by comparing size() with count.
| Count | The type of count. |
| count | The number of bits to construct. |
| value | The value of each bit. |
| max_size_max | Clamping value for the maximum size of this array. That is, cetl::variable_length_array::max_size() will return std::min(max_size_max, std::allocator_traits<allocator_type>::max_size(alloc)) |
| alloc | Allocator to use for all allocations. |
| std::length_error | if count is greater than max_size(). |
| std::bad_alloc | if the container cannot obtain enough memory to hold count bits. |
References resize().
|
inline |
Count-value constructor.
Constructs count copies of value, as std::vector<bool>(count, value, alloc) does. Has the same guarantees as the constructor that also takes max_size_max.
| Count | The type of count. |
| count | The number of bits to construct. |
| value | The value of each bit. |
| alloc | Allocator to use for all allocations. |
| std::length_error | if count is greater than max_size(). |
| std::bad_alloc | if the container cannot obtain enough memory to hold count bits. |
References variable_length_array().
|
inline |
Range constructor with maximum max size.
| InputIt | The type of the range's iterators. |
| first | The beginning of the range. |
| last | The end of the range. |
| max_size_max | Clamping value for the maximum size of this array. That is, cetl::variable_length_array::max_size() will return std::min(max_size_max, / std::allocator_traits<allocator_type>::max_size(alloc)) |
| alloc | Allocator to use for all allocations. |
References assign().
|
inline |
Range constructor.
| InputIt | The type of the range's iterators. |
| first | The beginning of the range. |
| last | The end of the range. |
| alloc | Allocator to use for all allocations. |
References variable_length_array().
|
inlineexplicitnoexcept |
Required constructor for std::uses_allocator protocol.
| alloc | Allocator to use for all allocations. |
|
inlineexplicitnoexcept |
Required constructor for std::uses_allocator protocol.
| max_size_max | Clamping value for the maximum size of this array. That is, cetl::variable_length_array::max_size() will return std::min(max_size_max, std::allocator_traits<allocator_type>::max_size(alloc)) |
| alloc | Allocator to use for all allocations. |
|
inline |
Initializer syntax constructor with maximum max size.
| l | Initializer list of elements to copy into the array. |
| max_size_max | Clamping value for the maximum size of this array. That is, cetl::variable_length_array::max_size() will return std::min(max_size_max, std::allocator_traits<allocator_type>::max_size(alloc)) |
| alloc | Allocator to use for all allocations. |
|
inline |
Initializer syntax constructor.
| l | Initializer list of elements to copy into the array. |
| alloc | Allocator to use for all allocations. |
|
inline |
Count-value constructor with maximum max size.
Constructs count copies of value, as std::vector(count, value, alloc) does, allocating storage for exactly count elements. The count may be any type that converts to size_type, but not a braced list: variable_length_array({x}, n, alloc) selects the initializer-list constructor. There is no (count, alloc) overload, because variable_length_array(n, alloc) sets max_size_max. With exceptions disabled, the array is truncated to max_size() or to the storage the allocator provides, which the caller can detect by comparing size() with count.
| Count | The type of count. |
| count | The number of elements to construct. |
| value | The value to copy into each element. |
| max_size_max | Clamping value for the maximum size of this array. That is, cetl::variable_length_array::max_size() will return std::min(max_size_max, std::allocator_traits<allocator_type>::max_size(alloc)) |
| alloc | Allocator to use for all allocations. |
| std::length_error | if count is greater than max_size(). |
| std::bad_alloc | if the container cannot obtain enough memory to hold count elements. |
|
inline |
Count-value constructor.
Constructs count copies of value, as std::vector(count, value, alloc) does. Has the same guarantees as the constructor that also takes max_size_max.
| Count | The type of count. |
| count | The number of elements to construct. |
| value | The value to copy into each element. |
| alloc | Allocator to use for all allocations. |
| std::length_error | if count is greater than max_size(). |
| std::bad_alloc | if the container cannot obtain enough memory to hold count elements. |
|
inline |
Range constructor with maximum max size.
| InputIt | The type of the range's iterators. |
| first | The beginning of the range. |
| last | The end of the range. |
| max_size_max | Clamping value for the maximum size of this array. That is, cetl::variable_length_array::max_size() will return std::min(max_size_max, / std::allocator_traits<allocator_type>::max_size(alloc)) |
| alloc | Allocator to use for all allocations. |
|
inline |
Range constructor.
| InputIt | The type of the range's iterators. |
| first | The beginning of the range. |
| last | The end of the range. |
| alloc | Allocator to use for all allocations. |
|
inline |
Replace the contents with the elements in [first, last), reusing existing storage where possible.
Single-pass input iterators are traversed once; forward ranges are measured before assignment. Move iterators move from the source elements. Forward ranges require no relocation of existing elements. The source range must not refer to elements of this array.
Forward ranges are checked against max_size() before anything changes. They release insufficient storage and then allocate storage for the whole range at once; if that allocation fails the array is left empty. Single-pass ranges grow one element at a time and detect an excessive length only on reaching max_size(), after the first max_size() elements have been assigned. If any element operation, iterator operation, allocation, or single-pass length check fails, the array remains valid but may be partially updated.
With exceptions disabled, forward ranges are truncated to max_size() or left empty by failed allocation, which the caller can detect by comparing size() with std::distance(first, last). Single-pass ranges stop at max_size() or at failed growth and keep the assigned prefix; the element that could not be stored is consumed. That cannot be distinguished from a source that ended at the same length, so bound single-pass sources by the remaining max_size() and reserve() capacity beforehand when truncation must be detected.
| std::length_error | if the source range exceeds max_size(). |
| std::bad_alloc | if storage cannot be obtained: for the whole forward range, or for the next element of a single-pass range. |
|
inline |
Replace the contents with the bits in [first, last), reusing existing storage where possible.
Single-pass input iterators are traversed once; forward ranges are measured before assignment. The source range must not refer to elements of this array.
Forward ranges are checked against max_size() before anything changes. They release insufficient storage and then allocate storage for the whole range at once; if that allocation fails the array is left empty. Single-pass ranges grow one bit at a time and detect an excessive length only on reaching max_size(), after the first max_size() bits have been assigned. If any iterator operation, value conversion, allocation, or single-pass length check fails, the array remains valid but may be partially updated.
With exceptions disabled, forward ranges are truncated to max_size() or left empty by failed allocation, which the caller can detect by comparing size() with std::distance(first, last). Single-pass ranges stop at max_size() or at failed growth and keep the assigned prefix; the bit that could not be stored is consumed. That cannot be distinguished from a source that ended at the same length, so bound single-pass sources by the remaining max_size() and reserve() capacity beforehand when truncation must be detected.
| std::length_error | if the source range exceeds max_size(). |
| std::bad_alloc | if storage cannot be obtained: for the whole forward range, or for the next bit of a single-pass range. |
|
inlineconstexpr |
Set count elements to the given value.
Grow the array if needed else set the size to count without reducing capacity. Like assign(first, last), insufficient storage is released before replacement storage is allocated.
| count | Number of elements, starting from 0, to set. |
| value | The value to set. |
| std::length_error | if the size requested is greater than max_size(). |
| std::bad_alloc | if the container cannot obtain enough memory to size up to count. |
References capacity(), clear(), max_size(), std::memset(), std::min(), and resize().
Referenced by assign(), operator=(), and variable_length_array().

|
inlineconstexpr |
Set count elements to the given value.
Grow the array if needed else set the size to count without reducing capacity. Like assign(first, last), insufficient storage is released before replacement storage is allocated, so growth needs no relocation; allocation failure or a throwing copy then leaves the array empty or partial.
| count | Number of elements, starting from 0, to set. |
| value | The value to set. It must not refer to an element of this array. |
| std::length_error | if the size requested is greater than max_size(). |
| std::bad_alloc | if the container cannot obtain enough memory to size up to count. |
|
inline |
Replace the contents with the initializer list. Has the same guarantees as assign(first, last).
References assign(), std::initializer_list::begin(), and std::initializer_list::end().
|
inline |
Replace the contents with the initializer list. Has the same guarantees as assign(first, last).
|
inlineconstexpr |
Returns a reference to the element at specified location pos, with bounds checking.
| pos | Position of the element to return. |
|
inlineconstexpr |
Returns a reference to the element at specified location pos, with bounds checking.
| pos | Position of the element to return. |
References operator[](), and size().
|
inlineconstexpr |
Returns a const reference to the element at specified location pos, with bounds checking.
| pos | Position of the element to return. |
|
inlineconstexpr |
Returns a const reference to the element at specified location pos, with bounds checking.
| pos | Position of the element to return. |
References operator[](), and size().
|
inlineconstexpr |
Returns a reference to the last element in the array.
Calling this method on an empty array is undefined.
|
inlineconstexpr |
Returns a reference to the last element in the array.
Calling this method on an empty array is undefined.
References front(), operator[](), and size().
|
inlineconstexpr |
Returns a const reference to the last element in the array.
Calling this method on an empty array is undefined.
|
inlineconstexpr |
Returns a const reference to the last element in the array.
Calling this method on an empty array is undefined.
References front(), operator[](), and size().
|
inlineconstexprnoexcept |
Provides direct, unsafe access to the internal data buffer.
This pointer is invalidated by calls to shrink_to_fit and reserve.
|
inlineconstexprnoexcept |
The number of elements that can be stored in the array without further allocations.
This number will only grow through calls to reserve and can shrink through calls to shrink_to_fit. This value shall never exceed max_size.
|
inlineconstexprnoexcept |
The number of elements that can be stored in the array without further allocations.
This number will only grow through calls to reserve and can shrink through calls to shrink_to_fit. This value shall never exceed max_size.
Referenced by assign().

|
inlineconstexprnoexcept |
Provides direct, unsafe access to the internal data buffer.
This pointer is invalidated by calls to shrink_to_fit and reserve.
|
inlineconstexprnoexcept |
The returned iterators are invalidated by calls to shrink_to_fit and reserve.
|
inlineconstexprnoexcept |
Pointer to memory location after the last, valid element.
This pointer is invalidated by calls to shrink_to_fit and reserve.
|
inlineconstexprnoexcept |
Destroys all elements in the list but does not release any capacity.
Referenced by assign().

|
inlineconstexprnoexcept |
Destroys all elements in the list but does not release any capacity.
|
inlineconstexprnoexcept |
Provides direct, unsafe access to the internal data buffer.
This pointer is invalidated by calls to shrink_to_fit and reserve.
|
inlineconstexprnoexcept |
Provides direct, unsafe access to the internal data buffer.
This pointer is invalidated by calls to shrink_to_fit and reserve.
|
inline |
Like push_back but constructs the object directly in uninitialized memory.
As with std::vector, the arguments may refer to elements of this array, even when the call grows the storage.
| throw | std::length_error if there was not enough storage for an additional element. If exceptions are disabled then the caller must check the array size before and after calling the method to determine if it succeeded. |
|
inline |
Like push_back but constructs the object directly in uninitialized memory.
| throw | std::length_error if there was not enough storage for an additional element. If exceptions are disabled then the caller must check the array size before and after calling the method to determine if it succeeded. |
Referenced by insert(), and variable_length_array().

|
inlineconstexprnoexcept |
Query if the container has any elements in it at all.
true if the container is empty, false otherwise.
|
inlineconstexprnoexcept |
Query if the container has any elements in it at all.
true if the container is empty, false otherwise.
|
inlineconstexprnoexcept |
Pointer to memory location after the last, valid element.
This pointer is invalidated by calls to shrink_to_fit and reserve.
|
inlinenoexcept |
Removes the bits in [first, last), as std::vector<bool>::erase does.
Later bits move toward the front. Capacity and max_size() are unchanged, and iterators before first remain valid. An empty range has no effect.
| first | The first bit to remove. |
| last | One past the last bit to remove. [first, last) must be a valid range of this array. |
References CETL_DEBUG_ASSERT, set(), size(), and test().
|
inlinenoexcept |
Removes the elements in [first, last), as std::vector::erase does.
Later elements are move-assigned toward the front and the vacated elements at the end are destroyed. Capacity and max_size() are unchanged, and iterators before first remain valid. An empty range has no effect.
| first | The first element to remove. |
| last | One past the last element to remove. [first, last) must be a valid range of this array. |
| * | Any exception thrown by value_type's move assignment. The array then keeps its size and every element is valid, but elements from first onward may have been assigned or moved from. |
|
inlinenoexcept |
Removes the bit at pos, as std::vector<bool>::erase does.
Has the same guarantees as erase(first, last).
| pos | The bit to remove. It must be dereferenceable, so it cannot be end(). |
References CETL_DEBUG_ASSERT, erase(), and size().
Referenced by erase().

|
inlinenoexcept |
Removes the element at pos, as std::vector::erase does.
Has the same guarantees as erase(first, last).
| pos | The element to remove. It must be dereferenceable, so it cannot be end(). |
|
inlineconstexpr |
Returns a reference to the first element in the array.
Calling this method on an empty array is undefined.
|
inlineconstexpr |
Returns a reference to the first element in the array.
Calling this method on an empty array is undefined.
References CETL_DEBUG_ASSERT, operator[](), and size().
Referenced by back(), and back().

|
inlineconstexpr |
Returns a const reference to the first element in the array.
Calling this method on an empty array is undefined.
|
inlineconstexpr |
Returns a const reference to the first element in the array.
Calling this method on an empty array is undefined.
References CETL_DEBUG_ASSERT, operator[](), and size().
|
inlineconstexprnoexcept |
STL-like access to a copy of the internal allocator.
|
inlineconstexprnoexcept |
STL-like access to a copy of the internal allocator.
|
inline |
Inserts a bit with value before pos, as std::vector<bool>::insert does.
Has the same guarantees as insert(pos, count, value).
References insert().
Referenced by insert(), and insert().

|
inline |
Inserts count bits with value before pos, as std::vector<bool>::insert does.
Iterators at or after pos are invalidated, and all iterators are if capacity grows; capacity grows geometrically, as for push_back(). With exceptions disabled, an insertion that would exceed max_size(), or for which the allocator does not provide storage, has no effect; detect it by comparing size() before and after.
pos if nothing was inserted. | std::length_error | if size() + count would exceed max_size(). |
| std::bad_alloc | if the container cannot obtain enough memory. |
|
inline |
Inserts count copies of value before pos, as std::vector::insert does.
value may be an element of this array. Iterators at or after pos are invalidated, and all iterators are if capacity grows; capacity grows geometrically, as for push_back(), so repeated insertion takes amortized constant time per element moved.
The new elements are constructed at the end and rotated into place, so value_type must be move-assignable and swappable, as std::vector requires. If constructing a new element throws, the elements constructed so far are destroyed and the array is unchanged, although capacity acquired for the insertion may remain. If moving the existing elements throws, every element remains valid but their order is unspecified.
With exceptions disabled, an insertion that would exceed max_size(), or for which the allocator does not provide storage, has no effect; detect it by comparing size() before and after.
| pos | The element before which to insert; may be end(). |
| count | The number of copies to insert. |
| value | The value to copy. |
pos if nothing was inserted. | std::length_error | if size() + count would exceed max_size(). |
| std::bad_alloc | if the container cannot obtain enough memory. |
|
inline |
Inserts a copy of value before pos, as std::vector::insert does.
Has the same guarantees as insert(pos, count, value); value may be an element of this array.
|
inline |
Inserts the elements of [first, last) before pos, in order, as std::vector::insert does.
The range must not refer to elements of this array. Forward ranges are measured first and have the same guarantees as insert(pos, count, value). Single-pass ranges are appended one element at a time and then rotated into place; if that fails with exceptions enabled, the appended elements are destroyed and the array is otherwise unchanged. With exceptions disabled, a single-pass range stops at max_size() or at failed growth and keeps the inserted prefix, as assign(first, last) does.
pos if the range is empty. | std::length_error | if the inserted elements would exceed max_size(). |
| std::bad_alloc | if the container cannot obtain enough memory. |
|
inline |
Inserts the bits of [first, last) before pos, in order, as std::vector<bool>::insert does.
The range must not refer to this array. Forward ranges are measured and storage is obtained first; single-pass ranges grow one bit at a time. If reading or converting a source element throws, or a single-pass range exceeds max_size(), the appended bits are removed and the array is unchanged except, possibly, its capacity. With exceptions disabled, a forward range that does not fit has no effect, while a single-pass range stops at max_size() or at failed growth and keeps the inserted prefix, as assign(first, last) does.
pos if the range is empty. | std::length_error | if the inserted bits would exceed max_size(). |
| std::bad_alloc | if the container cannot obtain enough memory. |
References emplace_back(), and size().
|
inline |
Inserts the bits of values before pos.
Has the same guarantees as insert(pos, first, last).
pos if values is empty. References std::initializer_list::begin(), std::initializer_list::end(), and insert().
|
inline |
Inserts the elements of values before pos.
Has the same guarantees as insert(pos, first, last).
pos if values is empty.
|
inline |
Inserts value before pos by moving it, as std::vector::insert does.
Has the same guarantees as insert(pos, count, value). As for any rvalue argument, value must not refer to an element of this array.
|
inlineconstexprnoexcept |
Returns the, theoretical, maximum number of elements that can be stored in this container.
It does not take into account the current state of the allocator. That is, if the allocator is out of memory this method will still return the maximum number of elements that could be stored if the allocator had enough memory, however, it will always return the maximum size passed into the constructor if that value is less than the allocator's max_size.
|
inlineconstexprnoexcept |
Returns the, theoretical, maximum number of elements that can be stored in this container.
It does not take into account the current state of the allocator. That is, if the allocator is out of memory this method will still return the maximum number of elements that could be stored if the allocator had enough memory, however, it will always return the maximum size passed into the constructor if that value is less than the allocator's max_size.
References std::numeric_limits::max(), std::allocator_traits::max_size(), and std::min().
Referenced by assign(), reserve(), resize(), and variable_length_array().

|
inlineconstexpr |
Compares the elements lexicographically, as std::vector's operator< does before C++20: the first unequal pair decides, and otherwise the shorter array is less.
Requires value_type to be comparable with operator<. In C++20 these four operators are replaced by operator<=>, as they are for std::vector.
|
inlineconstexprnoexcept |
Compares the bits lexicographically, as std::vector<bool>'s operator< does: at the first differing bit, false is less than true, and otherwise the shorter array is less.
References std::min(), size(), test(), and variable_length_array().
|
inlineconstexpr |
Lexicographic comparison; see operator<.
|
inlineconstexprnoexcept |
Lexicographic comparison; see operator<.
References variable_length_array().
|
inline |
Replace the contents with the initializer list, keeping the allocator and max_size().
Equivalent to assign(values), with the same guarantees.
| values | The bits to copy into the array. |
*this | std::length_error | if values has more elements than max_size(). |
| std::bad_alloc | if the container cannot obtain enough memory to hold values. |
References assign(), and variable_length_array().
|
inline |
Replace the contents with the initializer list, keeping the allocator and max_size().
Equivalent to assign(values), with the same guarantees.
| values | The elements to copy into the array. |
*this | std::length_error | if values has more elements than max_size(). |
| std::bad_alloc | if the container cannot obtain enough memory to hold values. |
|
inlineconstexpr |
Lexicographic comparison; see operator<.
|
inlineconstexprnoexcept |
Lexicographic comparison; see operator<.
References variable_length_array().
|
inlineconstexpr |
Lexicographic comparison; see operator<.
|
inlineconstexprnoexcept |
Lexicographic comparison; see operator<.
References variable_length_array().
|
inlineconstexprnoexcept |
|
inlineconstexprnoexcept |
Direct, const access to an element.
If pos is > size the behavior is undefined.
The returned reference is valid while this object is unless reserve or shrink_to_fit is called.
|
inlineconstexprnoexcept |
Direct access to an element.
If pos is > size the behavior is undefined.
The returned reference is valid while this object is unless reserve or shrink_to_fit is called.
| pos | The index of the element to access. |
pos.
|
inlineconstexprnoexcept |
Remove and destroy the last item in the array.
This reduces the array size by 1 unless the array is already empty.
|
inlineconstexprnoexcept |
Remove and destroy the last item in the array.
This reduces the array size by 1 unless the array is already empty.
|
inlineconstexpr |
Construct a new element on to the back of the array.
Grows size by 1 and may grow capacity.
If exceptions are disabled the caller must check before and after to see if the size grew to determine success. If using exceptions_before = my_array.size(); my_array.push_back(); if (size_before = this method throws std::length_error if the size of this collection is at capacity or std::bad_alloc if the allocator failed to provide enough memory.
If exceptions are disabled use the following logic:
const size_t siz= my_array.size())
{
// failure
if (size_before == my_array.max_size())
{
// length_error: you probably should have checked this first.
}
else
{
// bad_alloc: out of memory
}
} // else, success.
| std::length_error | if the size of this collection is at capacity. |
| std::bad_alloc | if memory was needed and none could be allocated. |
|
inlineconstexpr |
Allocate a new element on to the back of the array and copy value into it.
Grows size by 1 and may grow capacity.
If exceptions are disabled the caller must check before and after to see if the size grew to determine success. If using exceptions this method throws std::length_error if the size of this collection is at capacity or std::bad_alloc if the allocator failed to provide enough memory.
If exceptions are disabled use the following logic:
const size_t size_before = my_array.size();
my_array.push_back(element);
if (size_before == my_array.size())
{
// failure
if (size_before == my_array.max_size())
{
// length_error: you probably should have checked this first.
}
else
{
// bad_alloc: out of memory
}
} // else, success.
|
inlineconstexpr |
Allocate a new element on to the back of the array and move value into it.
Grows size by 1 and may grow capacity.
See variable_length_array::push_back(value_type&) for full documentation.
| std::length_error | if the size of this collection is at capacity. |
| std::bad_alloc | if memory was needed and none could be allocated. |
|
inlineconstexprnoexcept |
A reverse iterator to the last element, or rend() if the array is empty.
Like the forward iterators, reverse iterators are invalidated by calls to shrink_to_fit and reserve.
|
inlineconstexprnoexcept |
Reverse iterators over the bits, from the last bit back to the first.
Like the forward iterators, they are invalidated by calls to shrink_to_fit and reserve.
|
inlineconstexprnoexcept |
A reverse iterator to the position before the first element.
|
inline |
Ensure enough memory is allocated to store at least the desired_capacity number of elements.
| desired_capacity | The number of elements to allocate, but not initialize, memory for. |
|
inline |
Ensure enough memory is allocated to store at least the desired_capacity number of elements.
| desired_capacity | The number of elements to allocate, but not initialize, memory for. |
References max_size().
|
inlineconstexpr |
Resizes internal storage to count elements default initializing any added elements over the current size() and deleting any elements under the current size().
If size() == count then this method has no effect.
| count | The new size to set for this container. |
| * | If exceptions are enabled then any exceptions that value_type constructors or destructors throw will escape this call |
| std::length_error | if the size requested is greater than max_size(). |
| std::bad_alloc | if the container cannot obtain enough memory to size up to count. |
|
inlineconstexpr |
Resizes internal storage to count elements default initializing any added elements over the current size() and deleting any elements under the current size().
If size() == count then this method has no effect.
| count | The new size, in bits, to set for this container. |
| std::length_error | if the size requested is greater than max_size(). |
| std::bad_alloc | if the container cannot obtain enough memory to size up to count. |
References resize().
Referenced by assign(), insert(), resize(), and variable_length_array().

|
inlineconstexpr |
Resizes internal storage to count elements copy-initializing any added elements over the current size() and deleting any elements under the current size().
If size() == count then this method has no effect.
| count | The new size, in bits, to set for this container. |
| value | The value to copy into any new elements created by the operation. |
| std::length_error | if the size requested is greater than max_size(). |
| std::bad_alloc | if the container cannot obtain enough memory to size up to count. |
References max_size(), and std::memset().
|
inlineconstexpr |
Resizes internal storage to count elements copy-initializing any added elements over the current size() and deleting any elements under the current size().
If size() == count then this method has no effect.
| count | The new size to set for this container. |
| value | The value to copy into any new elements created by the operation. |
| * | If exceptions are enabled then any exceptions that value_type constructors or destructors throw will escape this call |
| std::length_error | if the size requested is greater than max_size(). |
| std::bad_alloc | if the container cannot obtain enough memory to size up to count. |
|
inlinestaticconstexprnoexcept |
Sets the bit at the specified position to the specified value.
Does nothing if position is out of range.
References std::make_pair(), cetl::variable_length_array< T, Allocator >::size(), and variable_length_array().
Referenced by erase().

|
inline |
Reduce the amount of memory held by this object to the minimum required based on size.
This method may not actually deallocate any memory if there is not enough memory to allocate a smaller buffer before moving the existing elements and freeing the larger buffer. Allocation failure triggers a CETL_DEBUG_ASSERT when CETL_ENABLE_DEBUG_ASSERT is enabled; otherwise, the original buffer and capacity are retained and std::bad_alloc is suppressed.
| if | any items throw while being moved. |
|
inline |
Reduce the amount of memory held by this object to the minimum required based on size.
This method may not actually deallocate any memory if there is not enough memory to allocate a smaller buffer before moving the existing elements and freeing the larger buffer. Allocation failure triggers a CETL_DEBUG_ASSERT when CETL_ENABLE_DEBUG_ASSERT is enabled; otherwise, the original buffer and capacity are retained and std::bad_alloc is suppressed.
| if | any items throw while being moved. |
References CETL_DEBUG_ASSERT.
|
inlineconstexprnoexcept |
The current number of elements in the array.
This number increases with each successful call to push_back and decreases with each call to pop_back (when size is > 0).
|
inlineconstexprnoexcept |
The current number of elements in the array.
This number increases with each successful call to push_back and decreases with each call to pop_back (when size is > 0).
Referenced by at(), at(), back(), back(), erase(), erase(), front(), front(), insert(), insert(), and operator<().

|
inlinestaticnoexcept |
Exchanges two bits through their proxies, as std::vector<bool>::swap(reference, reference) does.
|
inlinestaticconstexprnoexcept |
Returns true iff the bit at the specified position is set and the argument is within the range.
References std::make_pair(), and variable_length_array().
Referenced by erase(), operator<(), and operator[]().
