CETL 2.1.0
 
Loading...
Searching...
No Matches
cetl::variable_length_array< bool, Allocator > Class Template Reference

#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
 

Detailed Description

template<typename Allocator>
class cetl::variable_length_array< bool, Allocator >

A memory-optimized specialization for bool storing 8 bits per byte.

The internal bit ordering is little-endian.

Template Parameters
AllocatorThe allocator type to use.

Member Typedef Documentation

◆ allocator_type

using cetl::variable_length_array< bool, Allocator >::allocator_type

Per the std::uses_allocator protocol.

◆ const_iterator

using cetl::variable_length_array< bool, Allocator >::const_iterator

STL-like declaration of the const iterator type.

◆ const_reference

using cetl::variable_length_array< bool, Allocator >::const_reference

STL-like declaration of constant-reference type.

◆ const_reverse_iterator

using cetl::variable_length_array< bool, Allocator >::const_reverse_iterator

STL-like declaration of the const reverse iterator type.

◆ difference_type

using cetl::variable_length_array< bool, Allocator >::difference_type

STL-like declaration of the container's difference type.

◆ iterator

using cetl::variable_length_array< bool, Allocator >::iterator

STL-like declaration of the iterator type.

◆ pointer

using cetl::variable_length_array< bool, Allocator >::pointer

STL-like declaration of pointer type.

◆ reference

using cetl::variable_length_array< bool, Allocator >::reference

STL-like declaration of reference type.

◆ reverse_iterator

using cetl::variable_length_array< bool, Allocator >::reverse_iterator

STL-like declaration of the reverse iterator type.

◆ size_type

using cetl::variable_length_array< bool, Allocator >::size_type

STL-like declaration of the container's size type.

◆ value_type

using cetl::variable_length_array< bool, Allocator >::value_type

STL-like declaration of the container's storage type.

Constructor & Destructor Documentation

◆ variable_length_array() [1/16]

template<typename Allocator>
cetl::variable_length_array< bool, Allocator >::variable_length_array ( size_type max_size_max,
const allocator_type & alloc )
inlineexplicitconstexprnoexcept

Required constructor for std::uses_allocator protocol with maximum max size.

Parameters
max_size_maxClamping 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
allocAllocator 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().

Here is the caller graph for this function:

◆ variable_length_array() [2/16]

template<typename Allocator>
cetl::variable_length_array< bool, Allocator >::variable_length_array ( const allocator_type & alloc)
inlineexplicitconstexprnoexcept

Required constructor for std::uses_allocator protocol.

Parameters
allocAllocator to use for all allocations.

References variable_length_array().

◆ variable_length_array() [3/16]

template<typename Allocator>
cetl::variable_length_array< bool, Allocator >::variable_length_array ( std::initializer_list< bool > l,
size_type max_size_max,
const allocator_type & alloc )
inline

Initializer syntax constructor with maximum max size.

Parameters
lInitializer list of elements to copy into the array.
max_size_maxClamping 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))
allocAllocator to use for all allocations.

References emplace_back(), max_size(), and std::initializer_list::size().

◆ variable_length_array() [4/16]

template<typename Allocator>
cetl::variable_length_array< bool, Allocator >::variable_length_array ( std::initializer_list< bool > l,
const allocator_type & alloc )
inline

Initializer syntax constructor.

Parameters
lInitializer list of elements to copy into the array.
allocAllocator to use for all allocations.

References variable_length_array().

◆ variable_length_array() [5/16]

template<typename Allocator>
template<typename Count, typename = detail::enable_if_count_t<Count, size_type>>
cetl::variable_length_array< bool, Allocator >::variable_length_array ( Count count,
const bool value,
size_type max_size_max,
const allocator_type & alloc )
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.

Template Parameters
CountThe type of count.
Parameters
countThe number of bits to construct.
valueThe value of each bit.
max_size_maxClamping 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))
allocAllocator to use for all allocations.
Exceptions
std::length_errorif count is greater than max_size().
std::bad_allocif the container cannot obtain enough memory to hold count bits.

References resize().

◆ variable_length_array() [6/16]

template<typename Allocator>
template<typename Count, typename = detail::enable_if_count_t<Count, size_type>>
cetl::variable_length_array< bool, Allocator >::variable_length_array ( Count count,
const bool value,
const allocator_type & alloc )
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.

Template Parameters
CountThe type of count.
Parameters
countThe number of bits to construct.
valueThe value of each bit.
allocAllocator to use for all allocations.
Exceptions
std::length_errorif count is greater than max_size().
std::bad_allocif the container cannot obtain enough memory to hold count bits.

References variable_length_array().

◆ variable_length_array() [7/16]

template<typename Allocator>
template<class InputIt, typename = detail::enable_if_input_iterator_t<InputIt>>
cetl::variable_length_array< bool, Allocator >::variable_length_array ( InputIt first,
InputIt last,
size_type max_size_max,
const allocator_type & alloc )
inline

Range constructor with maximum max size.

Template Parameters
InputItThe type of the range's iterators.
Parameters
firstThe beginning of the range.
lastThe end of the range.
max_size_maxClamping 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))
allocAllocator to use for all allocations.

References assign().

◆ variable_length_array() [8/16]

template<typename Allocator>
template<class InputIt, typename = detail::enable_if_input_iterator_t<InputIt>>
cetl::variable_length_array< bool, Allocator >::variable_length_array ( InputIt first,
InputIt last,
const allocator_type & alloc )
inline

Range constructor.

Template Parameters
InputItThe type of the range's iterators.
Parameters
firstThe beginning of the range.
lastThe end of the range.
allocAllocator to use for all allocations.

References variable_length_array().

◆ variable_length_array() [9/16]

cetl::variable_length_array< bool, Allocator >::variable_length_array ( const allocator_type & alloc)
inlineexplicitnoexcept

Required constructor for std::uses_allocator protocol.

Parameters
allocAllocator to use for all allocations.

◆ variable_length_array() [10/16]

cetl::variable_length_array< bool, Allocator >::variable_length_array ( size_type max_size_max,
const allocator_type & alloc )
inlineexplicitnoexcept

Required constructor for std::uses_allocator protocol.

Parameters
max_size_maxClamping 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))
allocAllocator to use for all allocations.

◆ variable_length_array() [11/16]

cetl::variable_length_array< bool, Allocator >::variable_length_array ( std::initializer_list< value_type > l,
size_type max_size_max,
const allocator_type & alloc )
inline

Initializer syntax constructor with maximum max size.

Parameters
lInitializer list of elements to copy into the array.
max_size_maxClamping 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))
allocAllocator to use for all allocations.

◆ variable_length_array() [12/16]

cetl::variable_length_array< bool, Allocator >::variable_length_array ( std::initializer_list< value_type > l,
const allocator_type & alloc )
inline

Initializer syntax constructor.

Parameters
lInitializer list of elements to copy into the array.
allocAllocator to use for all allocations.

◆ variable_length_array() [13/16]

cetl::variable_length_array< bool, Allocator >::variable_length_array ( Count count,
const value_type & value,
size_type max_size_max,
const allocator_type & alloc )
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.

Template Parameters
CountThe type of count.
Parameters
countThe number of elements to construct.
valueThe value to copy into each element.
max_size_maxClamping 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))
allocAllocator to use for all allocations.
Exceptions
std::length_errorif count is greater than max_size().
std::bad_allocif the container cannot obtain enough memory to hold count elements.

◆ variable_length_array() [14/16]

cetl::variable_length_array< bool, Allocator >::variable_length_array ( Count count,
const value_type & value,
const allocator_type & alloc )
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.

Template Parameters
CountThe type of count.
Parameters
countThe number of elements to construct.
valueThe value to copy into each element.
allocAllocator to use for all allocations.
Exceptions
std::length_errorif count is greater than max_size().
std::bad_allocif the container cannot obtain enough memory to hold count elements.

◆ variable_length_array() [15/16]

cetl::variable_length_array< bool, Allocator >::variable_length_array ( InputIt first,
InputIt last,
size_type max_size_max,
const allocator_type & alloc )
inline

Range constructor with maximum max size.

Template Parameters
InputItThe type of the range's iterators.
Parameters
firstThe beginning of the range.
lastThe end of the range.
max_size_maxClamping 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))
allocAllocator to use for all allocations.

◆ variable_length_array() [16/16]

cetl::variable_length_array< bool, Allocator >::variable_length_array ( InputIt first,
InputIt last,
const allocator_type & alloc )
inline

Range constructor.

Template Parameters
InputItThe type of the range's iterators.
Parameters
firstThe beginning of the range.
lastThe end of the range.
allocAllocator to use for all allocations.

Member Function Documentation

◆ assign() [1/6]

void cetl::variable_length_array< bool, Allocator >::assign ( InputIt first,
InputIt last )
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.

Exceptions
std::length_errorif the source range exceeds max_size().
std::bad_allocif storage cannot be obtained: for the whole forward range, or for the next element of a single-pass range.

◆ assign() [2/6]

template<typename Allocator>
template<typename InputIt, typename = detail::enable_if_input_iterator_t<InputIt>>
void cetl::variable_length_array< bool, Allocator >::assign ( InputIt first,
InputIt last )
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.

Exceptions
std::length_errorif the source range exceeds max_size().
std::bad_allocif storage cannot be obtained: for the whole forward range, or for the next bit of a single-pass range.

◆ assign() [3/6]

template<typename Allocator>
void cetl::variable_length_array< bool, Allocator >::assign ( size_type count,
const bool & value )
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.

Parameters
countNumber of elements, starting from 0, to set.
valueThe value to set.
Exceptions
std::length_errorif the size requested is greater than max_size().
std::bad_allocif 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().

Here is the caller graph for this function:

◆ assign() [4/6]

void cetl::variable_length_array< bool, Allocator >::assign ( size_type count,
const value_type & value )
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.

Parameters
countNumber of elements, starting from 0, to set.
valueThe value to set. It must not refer to an element of this array.
Exceptions
std::length_errorif the size requested is greater than max_size().
std::bad_allocif the container cannot obtain enough memory to size up to count.

◆ assign() [5/6]

template<typename Allocator>
void cetl::variable_length_array< bool, Allocator >::assign ( std::initializer_list< bool > values)
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().

◆ assign() [6/6]

void cetl::variable_length_array< bool, Allocator >::assign ( std::initializer_list< value_type > values)
inline

Replace the contents with the initializer list. Has the same guarantees as assign(first, last).

◆ at() [1/4]

reference cetl::variable_length_array< bool, Allocator >::at ( size_type pos)
inlineconstexpr

Returns a reference to the element at specified location pos, with bounds checking.

Note
This function is only available if exceptions are enabled since there is no valid way to implement it without exceptions.
Parameters
posPosition of the element to return.
Returns
Reference to the requested element.

◆ at() [2/4]

template<typename Allocator>
reference cetl::variable_length_array< bool, Allocator >::at ( size_type pos)
inlineconstexpr

Returns a reference to the element at specified location pos, with bounds checking.

Note
This function is only available if exceptions are enabled since there is no valid way to implement it without exceptions.
Parameters
posPosition of the element to return.
Returns
Reference to the requested element.

References operator[](), and size().

◆ at() [3/4]

const_reference cetl::variable_length_array< bool, Allocator >::at ( size_type pos) const
inlineconstexpr

Returns a const reference to the element at specified location pos, with bounds checking.

Note
This function is only available if exceptions are enabled since there is no valid way to implement it without exceptions.
Parameters
posPosition of the element to return.
Returns
Const reference to the requested element.

◆ at() [4/4]

template<typename Allocator>
const_reference cetl::variable_length_array< bool, Allocator >::at ( size_type pos) const
inlineconstexpr

Returns a const reference to the element at specified location pos, with bounds checking.

Note
This function is only available if exceptions are enabled since there is no valid way to implement it without exceptions.
Parameters
posPosition of the element to return.
Returns
Const reference to the requested element.

References operator[](), and size().

◆ back() [1/4]

reference cetl::variable_length_array< bool, Allocator >::back ( )
inlineconstexpr

Returns a reference to the last element in the array.

Calling this method on an empty array is undefined.

Returns
Reference to the last element in the array.

◆ back() [2/4]

template<typename Allocator>
reference cetl::variable_length_array< bool, Allocator >::back ( )
inlineconstexpr

Returns a reference to the last element in the array.

Calling this method on an empty array is undefined.

Returns
Reference to the last element in the array.

References front(), operator[](), and size().

◆ back() [3/4]

const_reference cetl::variable_length_array< bool, Allocator >::back ( ) const
inlineconstexpr

Returns a const reference to the last element in the array.

Calling this method on an empty array is undefined.

Returns
Constant reference to the last element in the array.

◆ back() [4/4]

template<typename Allocator>
const_reference cetl::variable_length_array< bool, Allocator >::back ( ) const
inlineconstexpr

Returns a const reference to the last element in the array.

Calling this method on an empty array is undefined.

Returns
Constant reference to the last element in the array.

References front(), operator[](), and size().

◆ begin()

iterator cetl::variable_length_array< bool, Allocator >::begin ( )
inlineconstexprnoexcept

Provides direct, unsafe access to the internal data buffer.

This pointer is invalidated by calls to shrink_to_fit and reserve.

Returns
An iterator to the first element in the array.

◆ capacity() [1/2]

size_type cetl::variable_length_array< bool, Allocator >::capacity ( ) const
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.

Returns
The current capacity of this object.

◆ capacity() [2/2]

template<typename Allocator>
size_type cetl::variable_length_array< bool, Allocator >::capacity ( ) const
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().

Here is the caller graph for this function:

◆ cbegin() [1/2]

const_iterator cetl::variable_length_array< bool, Allocator >::cbegin ( ) const
inlineconstexprnoexcept

Provides direct, unsafe access to the internal data buffer.

This pointer is invalidated by calls to shrink_to_fit and reserve.

◆ cbegin() [2/2]

template<typename Allocator>
const_iterator cetl::variable_length_array< bool, Allocator >::cbegin ( ) const
inlineconstexprnoexcept

The returned iterators are invalidated by calls to shrink_to_fit and reserve.

◆ cend()

const_iterator cetl::variable_length_array< bool, Allocator >::cend ( ) const
inlineconstexprnoexcept

Pointer to memory location after the last, valid element.

This pointer is invalidated by calls to shrink_to_fit and reserve.

◆ clear() [1/2]

template<typename Allocator>
void cetl::variable_length_array< bool, Allocator >::clear ( )
inlineconstexprnoexcept

Destroys all elements in the list but does not release any capacity.

Referenced by assign().

Here is the caller graph for this function:

◆ clear() [2/2]

void cetl::variable_length_array< bool, Allocator >::clear ( )
inlineconstexprnoexcept

Destroys all elements in the list but does not release any capacity.

◆ data() [1/2]

const value_type * cetl::variable_length_array< bool, Allocator >::data ( ) const
inlineconstexprnoexcept

Provides direct, unsafe access to the internal data buffer.

This pointer is invalidated by calls to shrink_to_fit and reserve.

◆ data() [2/2]

value_type * cetl::variable_length_array< bool, Allocator >::data ( )
inlineconstexprnoexcept

Provides direct, unsafe access to the internal data buffer.

This pointer is invalidated by calls to shrink_to_fit and reserve.

◆ emplace_back() [1/2]

void cetl::variable_length_array< bool, Allocator >::emplace_back ( Args &&... args)
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.

Exceptions
throwstd::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.

◆ emplace_back() [2/2]

template<typename Allocator>
void cetl::variable_length_array< bool, Allocator >::emplace_back ( bool value)
inline

Like push_back but constructs the object directly in uninitialized memory.

Exceptions
throwstd::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().

Here is the caller graph for this function:

◆ empty() [1/2]

bool cetl::variable_length_array< bool, Allocator >::empty ( ) const
inlineconstexprnoexcept

Query if the container has any elements in it at all.

Returns
true if the container is empty, false otherwise.

◆ empty() [2/2]

template<typename Allocator>
bool cetl::variable_length_array< bool, Allocator >::empty ( ) const
inlineconstexprnoexcept

Query if the container has any elements in it at all.

Returns
true if the container is empty, false otherwise.

◆ end()

iterator cetl::variable_length_array< bool, Allocator >::end ( )
inlineconstexprnoexcept

Pointer to memory location after the last, valid element.

This pointer is invalidated by calls to shrink_to_fit and reserve.

◆ erase() [1/4]

template<typename Allocator>
iterator cetl::variable_length_array< bool, Allocator >::erase ( const_iterator first,
const_iterator last )
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.

Parameters
firstThe first bit to remove.
lastOne past the last bit to remove. [first, last) must be a valid range of this array.
Returns
An iterator to the bit that followed the removed range, which is end() if the range reached it.

References CETL_DEBUG_ASSERT, set(), size(), and test().

◆ erase() [2/4]

iterator cetl::variable_length_array< bool, Allocator >::erase ( const_iterator first,
const_iterator last )
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.

Parameters
firstThe first element to remove.
lastOne past the last element to remove. [first, last) must be a valid range of this array.
Returns
An iterator to the element that followed the removed range, which is end() if the range reached it.
Exceptions
*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.

◆ erase() [3/4]

template<typename Allocator>
iterator cetl::variable_length_array< bool, Allocator >::erase ( const_iterator pos)
inlinenoexcept

Removes the bit at pos, as std::vector<bool>::erase does.

Has the same guarantees as erase(first, last).

Parameters
posThe bit to remove. It must be dereferenceable, so it cannot be end().
Returns
An iterator to the bit that followed the removed one, which is end() if it was the last.

References CETL_DEBUG_ASSERT, erase(), and size().

Referenced by erase().

Here is the caller graph for this function:

◆ erase() [4/4]

iterator cetl::variable_length_array< bool, Allocator >::erase ( const_iterator pos)
inlinenoexcept

Removes the element at pos, as std::vector::erase does.

Has the same guarantees as erase(first, last).

Parameters
posThe element to remove. It must be dereferenceable, so it cannot be end().
Returns
An iterator to the element that followed the removed one, which is end() if it was the last.

◆ front() [1/4]

reference cetl::variable_length_array< bool, Allocator >::front ( )
inlineconstexpr

Returns a reference to the first element in the array.

Calling this method on an empty array is undefined.

Returns
Reference to the first element in the array.

◆ front() [2/4]

template<typename Allocator>
reference cetl::variable_length_array< bool, Allocator >::front ( )
inlineconstexpr

Returns a reference to the first element in the array.

Calling this method on an empty array is undefined.

Returns
Reference to the first element in the array.

References CETL_DEBUG_ASSERT, operator[](), and size().

Referenced by back(), and back().

Here is the caller graph for this function:

◆ front() [3/4]

const_reference cetl::variable_length_array< bool, Allocator >::front ( ) const
inlineconstexpr

Returns a const reference to the first element in the array.

Calling this method on an empty array is undefined.

Returns
Constant reference to the first element in the array.

◆ front() [4/4]

template<typename Allocator>
const_reference cetl::variable_length_array< bool, Allocator >::front ( ) const
inlineconstexpr

Returns a const reference to the first element in the array.

Calling this method on an empty array is undefined.

Returns
Constant reference to the first element in the array.

References CETL_DEBUG_ASSERT, operator[](), and size().

◆ get_allocator() [1/2]

allocator_type cetl::variable_length_array< bool, Allocator >::get_allocator ( ) const
inlineconstexprnoexcept

STL-like access to a copy of the internal allocator.

◆ get_allocator() [2/2]

template<typename Allocator>
allocator_type cetl::variable_length_array< bool, Allocator >::get_allocator ( ) const
inlineconstexprnoexcept

STL-like access to a copy of the internal allocator.

◆ insert() [1/9]

template<typename Allocator>
iterator cetl::variable_length_array< bool, Allocator >::insert ( const_iterator pos,
const bool value )
inline

Inserts a bit with value before pos, as std::vector<bool>::insert does.

Has the same guarantees as insert(pos, count, value).

Returns
An iterator to the inserted bit.

References insert().

Referenced by insert(), and insert().

Here is the caller graph for this function:

◆ insert() [2/9]

template<typename Allocator>
iterator cetl::variable_length_array< bool, Allocator >::insert ( const_iterator pos,
const size_type count,
const bool value )
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.

Returns
An iterator to the first inserted bit, or pos if nothing was inserted.
Exceptions
std::length_errorif size() + count would exceed max_size().
std::bad_allocif the container cannot obtain enough memory.

References resize(), and size().

◆ insert() [3/9]

iterator cetl::variable_length_array< bool, Allocator >::insert ( const_iterator pos,
const size_type count,
const value_type & value )
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.

Parameters
posThe element before which to insert; may be end().
countThe number of copies to insert.
valueThe value to copy.
Returns
An iterator to the first inserted element, or pos if nothing was inserted.
Exceptions
std::length_errorif size() + count would exceed max_size().
std::bad_allocif the container cannot obtain enough memory.

◆ insert() [4/9]

iterator cetl::variable_length_array< bool, Allocator >::insert ( const_iterator pos,
const value_type & value )
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.

Returns
An iterator to the inserted element.

◆ insert() [5/9]

iterator cetl::variable_length_array< bool, Allocator >::insert ( const_iterator pos,
InputIt first,
InputIt last )
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.

Returns
An iterator to the first inserted element, or pos if the range is empty.
Exceptions
std::length_errorif the inserted elements would exceed max_size().
std::bad_allocif the container cannot obtain enough memory.

◆ insert() [6/9]

template<typename Allocator>
template<typename InputIt, typename = detail::enable_if_input_iterator_t<InputIt>>
iterator cetl::variable_length_array< bool, Allocator >::insert ( const_iterator pos,
InputIt first,
InputIt last )
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.

Returns
An iterator to the first inserted bit, or pos if the range is empty.
Exceptions
std::length_errorif the inserted bits would exceed max_size().
std::bad_allocif the container cannot obtain enough memory.

References emplace_back(), and size().

◆ insert() [7/9]

template<typename Allocator>
iterator cetl::variable_length_array< bool, Allocator >::insert ( const_iterator pos,
std::initializer_list< bool > values )
inline

Inserts the bits of values before pos.

Has the same guarantees as insert(pos, first, last).

Returns
An iterator to the first inserted bit, or pos if values is empty.

References std::initializer_list::begin(), std::initializer_list::end(), and insert().

◆ insert() [8/9]

iterator cetl::variable_length_array< bool, Allocator >::insert ( const_iterator pos,
std::initializer_list< value_type > values )
inline

Inserts the elements of values before pos.

Has the same guarantees as insert(pos, first, last).

Returns
An iterator to the first inserted element, or pos if values is empty.

◆ insert() [9/9]

iterator cetl::variable_length_array< bool, Allocator >::insert ( const_iterator pos,
value_type && value )
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.

Returns
An iterator to the inserted element.

◆ max_size() [1/2]

size_type cetl::variable_length_array< bool, Allocator >::max_size ( ) const
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.

Returns
The maximum number of elements that could be stored in this container.

◆ max_size() [2/2]

template<typename Allocator>
size_type cetl::variable_length_array< bool, Allocator >::max_size ( ) const
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.

Returns
The maximum number of elements that could be stored in this container.

References std::numeric_limits::max(), std::allocator_traits::max_size(), and std::min().

Referenced by assign(), reserve(), resize(), and variable_length_array().

Here is the caller graph for this function:

◆ operator<() [1/2]

bool cetl::variable_length_array< bool, Allocator >::operator< ( const variable_length_array< bool, Allocator > & rhs) const
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.

◆ operator<() [2/2]

template<typename Allocator>
bool cetl::variable_length_array< bool, Allocator >::operator< ( const variable_length_array< bool, Allocator > & rhs) const
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().

◆ operator<=() [1/2]

bool cetl::variable_length_array< bool, Allocator >::operator<= ( const variable_length_array< bool, Allocator > & rhs) const
inlineconstexpr

Lexicographic comparison; see operator<.

◆ operator<=() [2/2]

template<typename Allocator>
bool cetl::variable_length_array< bool, Allocator >::operator<= ( const variable_length_array< bool, Allocator > & rhs) const
inlineconstexprnoexcept

Lexicographic comparison; see operator<.

References variable_length_array().

◆ operator=() [1/2]

template<typename Allocator>
variable_length_array & cetl::variable_length_array< bool, Allocator >::operator= ( std::initializer_list< bool > values)
inline

Replace the contents with the initializer list, keeping the allocator and max_size().

Equivalent to assign(values), with the same guarantees.

Parameters
valuesThe bits to copy into the array.
Returns
*this
Exceptions
std::length_errorif values has more elements than max_size().
std::bad_allocif the container cannot obtain enough memory to hold values.

References assign(), and variable_length_array().

◆ operator=() [2/2]

variable_length_array & cetl::variable_length_array< bool, Allocator >::operator= ( std::initializer_list< value_type > values)
inline

Replace the contents with the initializer list, keeping the allocator and max_size().

Equivalent to assign(values), with the same guarantees.

Parameters
valuesThe elements to copy into the array.
Returns
*this
Exceptions
std::length_errorif values has more elements than max_size().
std::bad_allocif the container cannot obtain enough memory to hold values.

◆ operator>() [1/2]

bool cetl::variable_length_array< bool, Allocator >::operator> ( const variable_length_array< bool, Allocator > & rhs) const
inlineconstexpr

Lexicographic comparison; see operator<.

◆ operator>() [2/2]

template<typename Allocator>
bool cetl::variable_length_array< bool, Allocator >::operator> ( const variable_length_array< bool, Allocator > & rhs) const
inlineconstexprnoexcept

Lexicographic comparison; see operator<.

References variable_length_array().

◆ operator>=() [1/2]

bool cetl::variable_length_array< bool, Allocator >::operator>= ( const variable_length_array< bool, Allocator > & rhs) const
inlineconstexpr

Lexicographic comparison; see operator<.

◆ operator>=() [2/2]

template<typename Allocator>
bool cetl::variable_length_array< bool, Allocator >::operator>= ( const variable_length_array< bool, Allocator > & rhs) const
inlineconstexprnoexcept

Lexicographic comparison; see operator<.

References variable_length_array().

◆ operator[]() [1/3]

template<typename Allocator>
const_reference cetl::variable_length_array< bool, Allocator >::operator[] ( const size_type pos) const
inlineconstexprnoexcept

This is an alias for test.

References test().

Referenced by at(), at(), back(), back(), front(), and front().

Here is the caller graph for this function:

◆ operator[]() [2/3]

const value_type & cetl::variable_length_array< bool, Allocator >::operator[] ( size_type pos) const
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.

◆ operator[]() [3/3]

value_type & cetl::variable_length_array< bool, Allocator >::operator[] ( size_type pos)
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.

Parameters
posThe index of the element to access.
Returns
A reference to the element at pos.

◆ pop_back() [1/2]

template<typename Allocator>
void cetl::variable_length_array< bool, Allocator >::pop_back ( )
inlineconstexprnoexcept

Remove and destroy the last item in the array.

This reduces the array size by 1 unless the array is already empty.

◆ pop_back() [2/2]

void cetl::variable_length_array< bool, Allocator >::pop_back ( )
inlineconstexprnoexcept

Remove and destroy the last item in the array.

This reduces the array size by 1 unless the array is already empty.

◆ push_back() [1/3]

template<typename Allocator>
void cetl::variable_length_array< bool, Allocator >::push_back ( bool value)
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.
Exceptions
std::length_errorif the size of this collection is at capacity.
std::bad_allocif memory was needed and none could be allocated.

◆ push_back() [2/3]

void cetl::variable_length_array< bool, Allocator >::push_back ( const value_type & value)
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.

◆ push_back() [3/3]

void cetl::variable_length_array< bool, Allocator >::push_back ( value_type && value)
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.

Exceptions
std::length_errorif the size of this collection is at capacity.
std::bad_allocif memory was needed and none could be allocated.

◆ rbegin() [1/2]

reverse_iterator cetl::variable_length_array< bool, Allocator >::rbegin ( )
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.

◆ rbegin() [2/2]

template<typename Allocator>
reverse_iterator cetl::variable_length_array< bool, Allocator >::rbegin ( )
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.

◆ rend()

reverse_iterator cetl::variable_length_array< bool, Allocator >::rend ( )
inlineconstexprnoexcept

A reverse iterator to the position before the first element.

◆ reserve() [1/2]

void cetl::variable_length_array< bool, Allocator >::reserve ( const size_type desired_capacity)
inline

Ensure enough memory is allocated to store at least the desired_capacity number of elements.

Parameters
desired_capacityThe number of elements to allocate, but not initialize, memory for.

◆ reserve() [2/2]

template<typename Allocator>
void cetl::variable_length_array< bool, Allocator >::reserve ( const size_type desired_capacity)
inline

Ensure enough memory is allocated to store at least the desired_capacity number of elements.

Parameters
desired_capacityThe number of elements to allocate, but not initialize, memory for.

References max_size().

◆ resize() [1/4]

void cetl::variable_length_array< bool, Allocator >::resize ( size_type 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.

Parameters
countThe new size to set for this container.
Exceptions
*If exceptions are enabled then any exceptions that value_type constructors or destructors throw will escape this call
std::length_errorif the size requested is greater than max_size().
std::bad_allocif the container cannot obtain enough memory to size up to count.

◆ resize() [2/4]

template<typename Allocator>
void cetl::variable_length_array< bool, Allocator >::resize ( size_type 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.

Parameters
countThe new size, in bits, to set for this container.
Exceptions
std::length_errorif the size requested is greater than max_size().
std::bad_allocif the container cannot obtain enough memory to size up to count.

References resize().

Referenced by assign(), insert(), resize(), and variable_length_array().

Here is the caller graph for this function:

◆ resize() [3/4]

template<typename Allocator>
void cetl::variable_length_array< bool, Allocator >::resize ( size_type count,
const bool value )
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.

Parameters
countThe new size, in bits, to set for this container.
valueThe value to copy into any new elements created by the operation.
Exceptions
std::length_errorif the size requested is greater than max_size().
std::bad_allocif the container cannot obtain enough memory to size up to count.

References max_size(), and std::memset().

◆ resize() [4/4]

void cetl::variable_length_array< bool, Allocator >::resize ( size_type count,
const value_type & value )
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.

Parameters
countThe new size to set for this container.
valueThe value to copy into any new elements created by the operation.
Exceptions
*If exceptions are enabled then any exceptions that value_type constructors or destructors throw will escape this call
std::length_errorif the size requested is greater than max_size().
std::bad_allocif the container cannot obtain enough memory to size up to count.

◆ set()

template<typename Allocator>
static constexpr void cetl::variable_length_array< bool, Allocator >::set ( variable_length_array< bool, Allocator > & container,
const size_type pos,
const bool value = true )
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().

Here is the caller graph for this function:

◆ shrink_to_fit() [1/2]

void cetl::variable_length_array< bool, Allocator >::shrink_to_fit ( )
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.

Exceptions
ifany items throw while being moved.

◆ shrink_to_fit() [2/2]

template<typename Allocator>
void cetl::variable_length_array< bool, Allocator >::shrink_to_fit ( )
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.

Exceptions
ifany items throw while being moved.

References CETL_DEBUG_ASSERT.

◆ size() [1/2]

size_type cetl::variable_length_array< bool, Allocator >::size ( ) const
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).

◆ size() [2/2]

template<typename Allocator>
size_type cetl::variable_length_array< bool, Allocator >::size ( ) const
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<().

Here is the caller graph for this function:

◆ swap()

template<typename Allocator>
static void cetl::variable_length_array< bool, Allocator >::swap ( reference lhs,
reference rhs )
inlinestaticnoexcept

Exchanges two bits through their proxies, as std::vector<bool>::swap(reference, reference) does.

◆ test()

template<typename Allocator>
static constexpr bool cetl::variable_length_array< bool, Allocator >::test ( const variable_length_array< bool, Allocator > & container,
const size_type pos )
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[]().

Here is the caller graph for this function:

The documentation for this class was generated from the following file: