|
iceoryx2
C++ Language Bindings
|
A resizable container with compile-time fixed static capacity and contiguous inplace storage. More...
#include <static_vector.hpp>
Classes | |
| class | UncheckedAccessor |
| Users of this class must ensure that all memory accesses stay within bounds of the accessed vector's memory. More... | |
| class | UncheckedConstAccessor |
Public Types | |
| using | ValueType = T |
| using | SizeType = size_t |
| using | DifferenceType = ptrdiff_t |
| using | Reference = T & |
| using | ConstReference = T const & |
| using | Pointer = T * |
| using | ConstPointer = T const * |
| using | Iterator = Pointer |
| using | ConstIterator = ConstPointer |
| using | OptionalReference = bb::Optional< std::reference_wrapper< T > > |
| using | OptionalConstReference = bb::Optional< std::reference_wrapper< T const > > |
Public Member Functions | |
| constexpr | StaticVector () noexcept=default |
| constexpr | StaticVector (StaticVector const &)=default |
| constexpr | StaticVector (StaticVector &&)=default |
| template<uint64_t M, std::enable_if_t<(Capacity >=M), bool > = true> | |
| constexpr | StaticVector (StaticVector< T, M > const &rhs) |
| Copy construct from a vector with smaller capacity. | |
| template<uint64_t M, std::enable_if_t<(Capacity >=M), bool > = true> | |
| constexpr | StaticVector (T const (&element_array)[M]) |
| Construct from a C-style array. | |
| IOX2_CONSTEXPR_DTOR | ~StaticVector ()=default |
| auto | operator= (StaticVector const &) -> StaticVector &=default |
| auto | operator= (StaticVector &&) -> StaticVector &=default |
| template<typename... Args, std::enable_if_t< std::is_constructible< T, Args... >::value, bool > = true> | |
| constexpr auto | try_emplace_back (Args &&... args) -> bool |
| template<typename... Args, std::enable_if_t< std::is_constructible< T, Args... >::value, bool > = true> | |
| constexpr auto | try_emplace_at (SizeType index, Args &&... args) -> bool |
| constexpr auto | try_erase_at (SizeType index) -> bool |
| constexpr auto | try_erase_at (SizeType begin_index, SizeType end_index) -> bool |
| constexpr auto | try_insert_at (SizeType index, T const &value) -> bool |
| constexpr auto | try_insert_at (SizeType index, T &&value) -> bool |
| constexpr auto | try_insert_at (SizeType index, SizeType count, T const &value) -> bool |
| template<typename Iter , typename Sentinel , std::enable_if_t< std::is_constructible< T, decltype(*std::declval< Iter >())>::value &&std::is_convertible< decltype(std::declval< Iter >()==std::declval< Sentinel >()), bool >::value , bool > | |
| constexpr auto | try_insert_at_unchecked (SizeType index, Iter it_begin, Sentinel it_end) -> bool |
| constexpr auto | try_insert_at_unchecked (SizeType index, std::initializer_list< T > init_list) |
| constexpr void | clear () |
| constexpr auto | try_push_back (T const &value) -> bool |
| constexpr auto | try_push_back (T &&value) -> bool |
| constexpr auto | try_pop_back () -> bool |
| constexpr auto | size () const noexcept -> SizeType |
| Retrieves the size of the vector. | |
| constexpr auto | empty () const -> bool |
| Checks whether the vector is currently empty. | |
| auto | element_at (SizeType index) -> OptionalReference |
| auto | element_at (SizeType index) const -> OptionalConstReference |
| auto | front_element () -> OptionalReference |
| auto | front_element () const -> OptionalConstReference |
| auto | back_element () -> OptionalReference |
| auto | back_element () const -> OptionalConstReference |
| auto | unchecked_access () -> UncheckedAccessor |
| Unchecked mutable access to the vector contents. | |
| auto | unchecked_access () const -> UncheckedConstAccessor |
| Unchecked immutable access to the vector contents. | |
| constexpr auto | static_memory_layout_metrics () noexcept |
Static Public Member Functions | |
| template<uint64_t N> | |
| static constexpr auto | from_value (const T &value) -> StaticVector |
| template<typename U = T, std::enable_if_t< std::is_default_constructible< U >::value, bool > = true> | |
| static constexpr auto | from_value (SizeType count) -> bb::Optional< StaticVector > |
| static constexpr auto | from_value (SizeType count, T const &value) -> bb::Optional< StaticVector > |
Construct a new vector with count copies of value. | |
| template<typename Iter , typename Sentinel , std::enable_if_t< std::is_constructible< T, decltype(*std::declval< Iter >())>::value &&std::is_convertible< decltype(std::declval< Iter >()==std::declval< Sentinel >()), bool >::value , bool > | |
| static constexpr auto | from_range_unchecked (Iter it_begin, Sentinel it_end) -> bb::Optional< StaticVector > |
| template<typename Range > | |
| static constexpr auto | from_range_unchecked (Range const &rng) -> bb::Optional< StaticVector > |
| static constexpr auto | from_initializer_list (std::initializer_list< T > init_list) -> bb::Optional< StaticVector > |
| static constexpr auto | capacity () noexcept -> SizeType |
| Retrieves the static capacity of the vector. | |
Friends | |
| template<typename , uint64_t > | |
| class | StaticVector |
| auto | operator== (StaticVector const &lhs, StaticVector const &rhs) -> bool |
| auto | operator!= (StaticVector const &lhs, StaticVector const &rhs) -> bool |
A resizable container with compile-time fixed static capacity and contiguous inplace storage.
Definition at line 35 of file static_vector.hpp.
| using iox2::bb::StaticVector< T, Capacity >::ConstIterator = ConstPointer |
Definition at line 48 of file static_vector.hpp.
| using iox2::bb::StaticVector< T, Capacity >::ConstPointer = T const* |
Definition at line 46 of file static_vector.hpp.
| using iox2::bb::StaticVector< T, Capacity >::ConstReference = T const& |
Definition at line 44 of file static_vector.hpp.
| using iox2::bb::StaticVector< T, Capacity >::DifferenceType = ptrdiff_t |
Definition at line 42 of file static_vector.hpp.
| using iox2::bb::StaticVector< T, Capacity >::Iterator = Pointer |
Definition at line 47 of file static_vector.hpp.
| using iox2::bb::StaticVector< T, Capacity >::OptionalConstReference = bb::Optional<std::reference_wrapper<T const> > |
Definition at line 50 of file static_vector.hpp.
| using iox2::bb::StaticVector< T, Capacity >::OptionalReference = bb::Optional<std::reference_wrapper<T> > |
Definition at line 49 of file static_vector.hpp.
| using iox2::bb::StaticVector< T, Capacity >::Pointer = T* |
Definition at line 45 of file static_vector.hpp.
| using iox2::bb::StaticVector< T, Capacity >::Reference = T& |
Definition at line 43 of file static_vector.hpp.
| using iox2::bb::StaticVector< T, Capacity >::SizeType = size_t |
Definition at line 41 of file static_vector.hpp.
| using iox2::bb::StaticVector< T, Capacity >::ValueType = T |
Definition at line 40 of file static_vector.hpp.
|
constexprdefaultnoexcept |
|
constexprdefault |
|
constexprdefault |
|
inlineconstexpr |
Copy construct from a vector with smaller capacity.
Definition at line 141 of file static_vector.hpp.
|
inlineexplicitconstexpr |
Construct from a C-style array.
Definition at line 148 of file static_vector.hpp.
References iox2::bb::StaticVector< T, Capacity >::try_push_back().
|
default |
|
inline |
Attempts to retrieve the last element.
Definition at line 451 of file static_vector.hpp.
References iox2::bb::StaticVector< T, Capacity >::empty(), iox2::bb::NULLOPT, iox2::bb::detail::RawByteStorage< T, Capacity >::pointer_from_index(), and iox2::bb::StaticVector< T, Capacity >::size().
|
inline |
Attempts to retrieve the last element.
Definition at line 462 of file static_vector.hpp.
References iox2::bb::StaticVector< T, Capacity >::empty(), iox2::bb::NULLOPT, iox2::bb::detail::RawByteStorage< T, Capacity >::pointer_from_index(), and iox2::bb::StaticVector< T, Capacity >::size().
|
inlinestaticconstexprnoexcept |
Retrieves the static capacity of the vector.
Definition at line 390 of file static_vector.hpp.
|
inlineconstexpr |
Clears all elements from the vector. After this operation, the vector will be empty.
Definition at line 357 of file static_vector.hpp.
References iox2::bb::detail::RawByteStorage< T, Capacity >::erase_at(), and iox2::bb::detail::RawByteStorage< T, Capacity >::size().
|
inline |
Attempts to retrieve the element at index.
index is not 0 <= index < size(). Otherwise a reference to the element at the requested index. Definition at line 407 of file static_vector.hpp.
References iox2::bb::NULLOPT, iox2::bb::detail::RawByteStorage< T, Capacity >::pointer_from_index(), and iox2::bb::detail::RawByteStorage< T, Capacity >::size().
|
inline |
Attempts to retrieve the element at index.
index is not 0 <= index < size(). Otherwise a reference to the element at the requested index. Definition at line 418 of file static_vector.hpp.
References iox2::bb::NULLOPT, iox2::bb::detail::RawByteStorage< T, Capacity >::pointer_from_index(), and iox2::bb::detail::RawByteStorage< T, Capacity >::size().
|
inlineconstexpr |
Checks whether the vector is currently empty.
Definition at line 400 of file static_vector.hpp.
References iox2::bb::StaticVector< T, Capacity >::size().
Referenced by iox2::bb::StaticVector< T, Capacity >::back_element(), iox2::bb::StaticVector< T, Capacity >::back_element(), iox2::bb::StaticVector< T, Capacity >::front_element(), and iox2::bb::StaticVector< T, Capacity >::front_element().
|
inlinestaticconstexpr |
Constructs a vector from the elements of the initializer list init_list.
Definition at line 232 of file static_vector.hpp.
References iox2::bb::StaticVector< T, Capacity >::from_range_unchecked(), and iox2::bb::NULLOPT.
|
inlinestaticconstexpr |
Construct a vector from a range [it_begin, it_end). Users must ensure that it_end is reachable from it_begin without causing undefined behaviour.
Definition at line 205 of file static_vector.hpp.
References iox2::bb::NULLOPT.
Referenced by iox2::bb::StaticVector< T, Capacity >::from_initializer_list(), iox2::bb::StaticVector< T, Capacity >::from_range_unchecked(), iox2::BackpressureInfo::receiver_port_id(), iox2::DegradationInfo::receiver_port_id(), iox2::BackpressureInfo::sender_port_id(), iox2::DegradationInfo::sender_port_id(), iox2::BackpressureInfo::service_id(), and iox2::DegradationInfo::service_id().
|
inlinestaticconstexpr |
Constructs a vector from a range [begin(rng), end(rng)). Users must ensure that rng is represents a valid range object.
Definition at line 222 of file static_vector.hpp.
References iox2::bb::StaticVector< T, Capacity >::from_range_unchecked().
|
inlinestaticconstexpr |
Definition at line 162 of file static_vector.hpp.
References iox2::bb::detail::RawByteStorage< T, Capacity >::insert_at().
Referenced by iox2::bb::StaticVector< T, Capacity >::from_value().
|
inlinestaticconstexpr |
Construct a new vector with count occurrences of a default constructed value.
count exceeds the vector capacity. Otherwise a vector containing the desired elements. Definition at line 174 of file static_vector.hpp.
References iox2::bb::StaticVector< T, Capacity >::from_value(), and iox2::bb::NULLOPT.
|
inlinestaticconstexpr |
Construct a new vector with count copies of value.
Definition at line 183 of file static_vector.hpp.
References iox2::bb::detail::RawByteStorage< T, Capacity >::insert_at(), and iox2::bb::NULLOPT.
|
inline |
Attempts to retrieve the first element.
Definition at line 429 of file static_vector.hpp.
References iox2::bb::StaticVector< T, Capacity >::empty(), iox2::bb::NULLOPT, and iox2::bb::detail::RawByteStorage< T, Capacity >::pointer_from_index().
|
inline |
Attempts to retrieve the first element.
Definition at line 440 of file static_vector.hpp.
References iox2::bb::StaticVector< T, Capacity >::empty(), iox2::bb::NULLOPT, and iox2::bb::detail::RawByteStorage< T, Capacity >::pointer_from_index().
|
default |
|
default |
|
inlineconstexprnoexcept |
Retrieves the size of the vector.
Definition at line 395 of file static_vector.hpp.
References iox2::bb::detail::RawByteStorage< T, Capacity >::size().
Referenced by iox2::bb::StaticVector< T, Capacity >::back_element(), iox2::bb::StaticVector< T, Capacity >::back_element(), iox2::bb::StaticVector< T, Capacity >::empty(), and iox2::bb::StaticVector< T, Capacity >::try_insert_at_unchecked().
|
inlineconstexprnoexcept |
Obtains metrics about the internal memory layout of the vector. This function is intended for internal use only.
Definition at line 494 of file static_vector.hpp.
References iox2::bb::detail::RawByteStorage< T, Capacity >::static_memory_layout_metrics().
|
inlineconstexpr |
Attempts to construct a new element from the constructor arguments args at the specified index.
index is greater than the current size of the vector or if the operation would exceed the vector's capacity. Definition at line 258 of file static_vector.hpp.
References iox2::bb::detail::RawByteStorage< T, Capacity >::emplace_at(), and iox2::bb::detail::RawByteStorage< T, Capacity >::size().
Referenced by iox2::bb::StaticVector< T, Capacity >::try_insert_at(), and iox2::bb::StaticVector< T, Capacity >::try_insert_at().
|
inlineconstexpr |
Attempts to construct a new element from the constructor arguments args at the back of the vector.
Definition at line 244 of file static_vector.hpp.
References iox2::bb::detail::RawByteStorage< T, Capacity >::emplace_back(), and iox2::bb::detail::RawByteStorage< T, Capacity >::size().
Referenced by iox2::bb::StaticVector< T, Capacity >::try_push_back(), and iox2::bb::StaticVector< T, Capacity >::try_push_back().
|
inlineconstexpr |
Attempts to erase all elements in the index range [begin_index, end_index).
Definition at line 282 of file static_vector.hpp.
References iox2::bb::detail::RawByteStorage< T, Capacity >::erase_at(), and iox2::bb::detail::RawByteStorage< T, Capacity >::size().
|
inlineconstexpr |
Attempts to erase the element at the specified index.
index is not the index of an existing element. Definition at line 270 of file static_vector.hpp.
References iox2::bb::detail::RawByteStorage< T, Capacity >::erase_at(), and iox2::bb::detail::RawByteStorage< T, Capacity >::size().
|
inlineconstexpr |
Attempts to insert count copies of value at index.
index is greater than the current size of the vector or if the operation would exceed the vector's capacity. Definition at line 311 of file static_vector.hpp.
References iox2::bb::detail::RawByteStorage< T, Capacity >::insert_at(), and iox2::bb::detail::RawByteStorage< T, Capacity >::size().
|
inlineconstexpr |
Attempts to insert a single value at index. This function will move the input value into place.
index is greater than the current size of the vector. Definition at line 303 of file static_vector.hpp.
References iox2::bb::StaticVector< T, Capacity >::try_emplace_at().
|
inlineconstexpr |
Attempts to insert a single value at index. This function will copy the input value into place.
index is greater than the current size of the vector. Definition at line 295 of file static_vector.hpp.
References iox2::bb::StaticVector< T, Capacity >::try_emplace_at().
|
inlineconstexpr |
Attempts to insert the elements from the range [it_begin, it_end) at index. Users must ensure that it_end is reachable from it_begin without causing undefined behaviour.
index is greater than the current size of the vector or if the operation would exceed the vector's capacity. Definition at line 331 of file static_vector.hpp.
References iox2::bb::detail::RawByteStorage< T, Capacity >::rotate_from_back(), iox2::bb::detail::RawByteStorage< T, Capacity >::shrink_from_back(), iox2::bb::StaticVector< T, Capacity >::size(), iox2::bb::detail::RawByteStorage< T, Capacity >::size(), and iox2::bb::StaticVector< T, Capacity >::try_push_back().
Referenced by iox2::bb::StaticVector< T, Capacity >::try_insert_at_unchecked().
|
inlineconstexpr |
Attempts to insert the elements from the initializer list init_list at index.
index is greater than the current size of the vector or if the operation would exceed the vector's capacity. Definition at line 351 of file static_vector.hpp.
References iox2::bb::StaticVector< T, Capacity >::try_insert_at_unchecked().
|
inlineconstexpr |
Attempts to remove a single value from the back of the vector.
Definition at line 380 of file static_vector.hpp.
References iox2::bb::detail::RawByteStorage< T, Capacity >::shrink_from_back(), and iox2::bb::detail::RawByteStorage< T, Capacity >::size().
|
inlineconstexpr |
Attempts to insert a single value at the back of the vector. This function will move the input value into place.
index is greater than the current size of the vector. Definition at line 373 of file static_vector.hpp.
References iox2::bb::StaticVector< T, Capacity >::try_emplace_back().
|
inlineconstexpr |
Attempts to insert a single value at the back of the vector. This function will copy the input value into place.
index is greater than the current size of the vector. Definition at line 365 of file static_vector.hpp.
References iox2::bb::StaticVector< T, Capacity >::try_emplace_back().
Referenced by iox2::bb::StaticVector< T, Capacity >::StaticVector(), and iox2::bb::StaticVector< T, Capacity >::try_insert_at_unchecked().
|
inline |
Unchecked mutable access to the vector contents.
Definition at line 471 of file static_vector.hpp.
|
inline |
Unchecked immutable access to the vector contents.
Definition at line 476 of file static_vector.hpp.
|
friend |
Definition at line 488 of file static_vector.hpp.
|
friend |
Definition at line 481 of file static_vector.hpp.
|
friend |
Definition at line 128 of file static_vector.hpp.