|
Sen API
Sen Libraries
|
Base class for stack-based, exception-safe and resizable vector with fixed-capacity. More...
#include <static_vector.h>
Public Types | |
| using | value_type = T |
| using | difference_type = ptrdiff_t |
| using | pointer = T* |
| using | const_pointer = T const* |
| using | reference = T& |
| using | const_reference = T const& |
| using | rvalue_reference = T&& |
| using | iterator = pointer |
| using | const_iterator = const_pointer |
| using | size_type = std::size_t |
| using | reverse_iterator = std::reverse_iterator<iterator> |
| using | const_reverse_iterator = std::reverse_iterator<const_iterator> |
| using | Maybe = Result<void, StaticVectorError> |
| using | MaybeIterator = Result<iterator, StaticVectorError> |
Public Member Functions | |
| StaticVectorBase (const StaticVectorBase &) noexcept=delete | |
| StaticVectorBase (StaticVectorBase &&) noexcept=delete | |
| StaticVectorBase & | operator= (StaticVectorBase &&) noexcept=delete |
| StaticVectorBase & | operator= (const StaticVectorBase &) noexcept=delete |
| size_type | size () const noexcept |
| Element count. Complexity: constant. | |
| size_type | capacity () const noexcept |
| Maximum number of elements that can be allocated in the storage. Complexity: constant. | |
| size_type | maxSize () const noexcept |
| Max element count (same as capacity()). Complexity: constant. | |
| const_pointer | data () const noexcept |
| Direct access to the underlying storage. Complexity: constant. | |
| pointer | data () noexcept |
| Direct access to the underlying storage. Complexity: constant. | |
| bool | empty () const noexcept |
| true if the container is empty. Complexity: constant | |
| bool | full () const noexcept |
| true if the container is full. Complexity: constant | |
| Maybe | assign (size_type n, const T &u) noexcept(nothrowCopyCons) |
| Clears the vector and assigns n copies of u to it. Complexity: linear in n. | |
| Maybe | assign (const std::initializer_list< T > &list) noexcept(nothrowCopyCons) |
| Initializer list assignment. Complexity: linear in list.size(). | |
| Maybe | assign (std::initializer_list< T > &&list) noexcept(nothrowMoveCons) |
| Initializer list assignment (r-value version). Complexity: linear in list.size(). | |
| template<class InputIt> | |
| Maybe | assign (InputIt first, InputIt last) noexcept(nothrowCopyCons) |
| Clears the vector and assigns a range to it. Complexity: linear in distance(first, last). | |
| iterator | begin () noexcept |
| Returns an iterator to the first element of the vector. If the vector is empty, the returned iterator will be equal to end(). Complexity: constant. | |
| const_iterator | begin () const noexcept |
| Returns an iterator to the first element of the vector. If the vector is empty, the returned iterator will be equal to end(). Complexity: constant. | |
| iterator | end () noexcept |
| Iterator to the element following the last element. Complexity: constant. | |
| const_iterator | end () const noexcept |
| Iterator to the element following the last element. Complexity: constant. NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic). | |
| reverse_iterator | rbegin () noexcept |
| Reverse iterator to the first element. Complexity: constant. | |
| const_reverse_iterator | rbegin () const noexcept |
| Reverse iterator to the first element. Complexity: constant. | |
| reverse_iterator | rend () noexcept |
| Returns a reverse iterator to the element following the last element of the reversed vector. It corresponds to the element preceding the first element of the non-reversed vector. This element acts as a placeholder, attempting to access it results in undefined behavior. Complexity: constant. | |
| const_reverse_iterator | rend () const noexcept |
| Returns a reverse iterator to the element following the last element of the reversed vector. It corresponds to the element preceding the first element of the non-reversed vector. This element acts as a placeholder, attempting to access it results in undefined behavior. Complexity: constant. | |
| const_iterator | cbegin () noexcept |
| Returns a const iterator to the first element of the vector. If the vector is empty, the returned iterator will be equal to cend(). Complexity: constant. | |
| const_iterator | cbegin () const noexcept |
| Returns a const iterator to the first element of the vector. If the vector is empty, the returned iterator will be equal to cend(). Complexity: constant. | |
| const_iterator | cend () noexcept |
| Constant iterator to the element following the last element. Complexity: constant. | |
| const_iterator | cend () const noexcept |
| Constant iterator to the element following the last element. Complexity: constant. | |
| reference | operator[] (size_type i) noexcept |
| Gets the element at index i. Complexity: constant. | |
| const_reference | operator[] (size_type i) const noexcept |
| Gets the element at index i. Complexity: constant. | |
| reference | front () noexcept |
| The element at the beginning of the container. Calling front on an empty container is undefined. Complexity: constant. | |
| const_reference | front () const noexcept |
| The element at the beginning of the container (const version). Calling front on an empty container is undefined. Complexity: constant. | |
| reference | back () noexcept |
| The element at the end of the container. Calling back on an empty container is undefined. Complexity: constant. | |
| const_reference | back () const noexcept |
| The element at the end of the container (const version). Calling back on an empty container is undefined. Complexity: constant. | |
| void | clear () noexcept(nothrowDes) |
| Clears the vector. This function destroys all the elements. Complexity: linear in size(). | |
| Maybe | push_back (T &&value) noexcept(nothrowMoveCons) |
| Appends a value to the end of the container (r-value version). Complexity: constant. | |
| Maybe | push_back (const T &value) noexcept(nothrowCopyCons) |
| Appends a value to the end of the container. Complexity: constant. | |
| Maybe | push_back () noexcept(nothrowDefaultCons) |
| Appends a value (default constructed) to the end of the container. Complexity: constant. | |
| template<typename... Args> | |
| MaybeIterator | emplace (iterator position, Args &&... args) noexcept(nothrowMoveCons) |
| Inserts a new element into the container directly before pos. The arguments args... are forwarded to the constructor as std::forward<Args>(args) args... may directly or indirectly refer to a value in the container. | |
| template<typename... Args> | |
| Maybe | emplace_back (Args &&... args) noexcept(//NOLINT(readability-identifier-naming) nothrowMoveCons) |
| Constructs an element in-place at the end of the embedded storage. | |
| Maybe | pop_back () noexcept(nothrowDes) |
| Removes the last element of the container. Iterators and references to the last element, as well as the end() iterator, are invalidated. Complexity: constant. | |
| MaybeIterator | insert (iterator position, const_reference x) noexcept(nothrowCopyCons) |
| Inserts and element before position. Complexity: linear in size(). | |
| MaybeIterator | insert (iterator position, value_type &&x) noexcept(nothrowMoveCons) |
| Inserts and element before position (r-value version). Complexity: linear in size(). | |
| MaybeIterator | insert (iterator position, size_type n, const T &x) noexcept(nothrowCopyCons) |
| Inserts n copies of the value before pos Complexity: linear in size() and n. | |
| MaybeIterator | insert (iterator position, std::initializer_list< T > list) noexcept(nothrowCopyCons) |
| Inserts a range of values via initializer list. Complexity: linear in size() and list.size(). | |
| template<class InputIt> | |
| MaybeIterator | insert (iterator position, InputIt first, InputIt last) noexcept(nothrowCopyCons) |
| Inserts elements from range [first, last) before position. Complexity: linear in size() and distance(first, last). | |
| template<class InputIt> | |
| MaybeIterator | move_insert (iterator position, InputIt first, InputIt last) noexcept(nothrowMoveCons) |
| Inserts elements from range [first, last) before position (by moving them). Complexity: linear in size() and distance(first, last). | |
| Maybe | resize (size_type newSize, const T &value) noexcept(nothrowCopyAndDes) |
| Changes the size of the container to newSize. If need to be appended, elements are copy-constructed from value. Complexity: linear in newSize. | |
| Maybe | resize (size_type newSize) noexcept(nothrowDefaultConsAndDes) |
| Changes the size of the container to newSize. If need to be appended, elements are move-constructed from T{}. Complexity: linear in newSize. | |
| MaybeIterator | erase (iterator position) noexcept(nothrowDes) |
| Remove an element at position from the container. Complexity: linear in size(). | |
| MaybeIterator | erase (iterator first, iterator last) noexcept(nothrowDes) |
| Remove a range of elements from the container. Complexity: linear in size() and distance(first, last). | |
| template<class InputIt> | |
| void | internalDestroy (InputIt first, InputIt last) noexcept(nothrowDes) |
Static Public Attributes | |
| static constexpr bool | nothrowDes = std::is_nothrow_destructible_v<T> |
| static constexpr bool | nothrowDefaultCons = std::is_nothrow_default_constructible_v<T> |
| static constexpr bool | nothrowCopyCons = std::is_nothrow_copy_constructible_v<T> |
| static constexpr bool | nothrowMoveCons = std::is_nothrow_move_constructible_v<T> |
| static constexpr bool | nothrowCopyAndDes = nothrowDes && nothrowCopyCons |
| static constexpr bool | nothrowDefaultConsAndDes = nothrowDefaultCons && nothrowDes |
Protected Member Functions | |
| StaticVectorBase (std::size_t capacity, void *dataPtr) noexcept | |
| virtual | ~StaticVectorBase () noexcept |
| void | internalSetSize (std::size_t newSize) noexcept |
| Changes the container size to newSize. | |
Base class for stack-based, exception-safe and resizable vector with fixed-capacity.
Mimics the interface and general behavior of std::vector, but it does not perform memory allocations and does not make use of exceptions.
The idea is for it to be compatible with std algorithms and serve as a replacement for std::vector in constrained or real-time environments.
Use StaticVectorBase<T> when using vectors but not depending on their capacity.
| T | value type. |
| using sen::StaticVectorBase< T >::value_type = T |
| using sen::StaticVectorBase< T >::difference_type = ptrdiff_t |
| using sen::StaticVectorBase< T >::pointer = T* |
| using sen::StaticVectorBase< T >::const_pointer = T const* |
| using sen::StaticVectorBase< T >::reference = T& |
| using sen::StaticVectorBase< T >::const_reference = T const& |
| using sen::StaticVectorBase< T >::rvalue_reference = T&& |
| using sen::StaticVectorBase< T >::iterator = pointer |
| using sen::StaticVectorBase< T >::const_iterator = const_pointer |
| using sen::StaticVectorBase< T >::size_type = std::size_t |
| using sen::StaticVectorBase< T >::reverse_iterator = std::reverse_iterator<iterator> |
| using sen::StaticVectorBase< T >::const_reverse_iterator = std::reverse_iterator<const_iterator> |
| using sen::StaticVectorBase< T >::Maybe = Result<void, StaticVectorError> |
| using sen::StaticVectorBase< T >::MaybeIterator = Result<iterator, StaticVectorError> |
|
deletenoexcept |
|
deletenoexcept |
|
inlineprotectednoexcept |
|
inlineprotectedvirtualnoexcept |
|
deletenoexcept |
|
deletenoexcept |
|
inlinenodiscardnoexcept |
Element count. Complexity: constant.
|
inlinenodiscardnoexcept |
Maximum number of elements that can be allocated in the storage. Complexity: constant.
|
inlinenodiscardnoexcept |
Max element count (same as capacity()). Complexity: constant.
|
inlinenodiscardnoexcept |
Direct access to the underlying storage. Complexity: constant.
|
inlinenodiscardnoexcept |
Direct access to the underlying storage. Complexity: constant.
|
inlinenodiscardnoexcept |
true if the container is empty. Complexity: constant
|
inlinenodiscardnoexcept |
true if the container is full. Complexity: constant
|
inlinenodiscardnoexcept |
Clears the vector and assigns n copies of u to it. Complexity: linear in n.
| n | the number of elements to assign. |
| u | the value to be copied in. |
|
inlinenodiscardnoexcept |
Initializer list assignment. Complexity: linear in list.size().
| list | elements to be stored in the vector. |
|
inlinenodiscardnoexcept |
Initializer list assignment (r-value version). Complexity: linear in list.size().
| list | elements to be stored in the vector. |
|
inlinenodiscardnoexcept |
Clears the vector and assigns a range to it. Complexity: linear in distance(first, last).
|
inlinenodiscardnoexcept |
Returns an iterator to the first element of the vector. If the vector is empty, the returned iterator will be equal to end(). Complexity: constant.
|
inlinenodiscardnoexcept |
Returns an iterator to the first element of the vector. If the vector is empty, the returned iterator will be equal to end(). Complexity: constant.
|
inlinenodiscardnoexcept |
Iterator to the element following the last element. Complexity: constant.
|
inlinenodiscardnoexcept |
Iterator to the element following the last element. Complexity: constant. NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic).
|
inlinenodiscardnoexcept |
Reverse iterator to the first element. Complexity: constant.
|
inlinenodiscardnoexcept |
Reverse iterator to the first element. Complexity: constant.
|
inlinenodiscardnoexcept |
Returns a reverse iterator to the element following the last element of the reversed vector. It corresponds to the element preceding the first element of the non-reversed vector. This element acts as a placeholder, attempting to access it results in undefined behavior. Complexity: constant.
|
inlinenodiscardnoexcept |
Returns a reverse iterator to the element following the last element of the reversed vector. It corresponds to the element preceding the first element of the non-reversed vector. This element acts as a placeholder, attempting to access it results in undefined behavior. Complexity: constant.
|
inlinenodiscardnoexcept |
Returns a const iterator to the first element of the vector. If the vector is empty, the returned iterator will be equal to cend(). Complexity: constant.
|
inlinenodiscardnoexcept |
Returns a const iterator to the first element of the vector. If the vector is empty, the returned iterator will be equal to cend(). Complexity: constant.
|
inlinenodiscardnoexcept |
Constant iterator to the element following the last element. Complexity: constant.
|
inlinenodiscardnoexcept |
Constant iterator to the element following the last element. Complexity: constant.
|
inlinenodiscardnoexcept |
Gets the element at index i. Complexity: constant.
| i | index of the element to fetch. |
|
inlinenodiscardnoexcept |
Gets the element at index i. Complexity: constant.
| i | index of the element to fetch. |
|
inlinenodiscardnoexcept |
The element at the beginning of the container. Calling front on an empty container is undefined. Complexity: constant.
|
inlinenodiscardnoexcept |
The element at the beginning of the container (const version). Calling front on an empty container is undefined. Complexity: constant.
|
inlinenodiscardnoexcept |
The element at the end of the container. Calling back on an empty container is undefined. Complexity: constant.
|
inlinenodiscardnoexcept |
The element at the end of the container (const version). Calling back on an empty container is undefined. Complexity: constant.
|
inlinenoexcept |
|
inlinenoexcept |
Appends a value to the end of the container (r-value version). Complexity: constant.
NOLINTNEXTLINE(readability-identifier-naming)
|
inlinenoexcept |
Appends a value to the end of the container. Complexity: constant.
NOLINTNEXTLINE(readability-identifier-naming)
|
inlinenoexcept |
Appends a value (default constructed) to the end of the container. Complexity: constant.
NOLINTNEXTLINE(readability-identifier-naming)
|
inlinenoexcept |
Inserts a new element into the container directly before pos. The arguments args... are forwarded to the constructor as std::forward<Args>(args) args... may directly or indirectly refer to a value in the container.
Only the iterators and references before the insertion point remain valid. The past-the-end iterator is also invalidated.
Complexity: linear in size().
|
inlinenoexcept |
Constructs an element in-place at the end of the embedded storage.
Appends a new element to the end of the container. The arguments args... are forwarded to the constructor as std::forward<Args>(args)
Only the past-the-end iterator is invalidated.
Complexity: constant
| Args | - arguments for constructing the element. |
|
inlinenoexcept |
Removes the last element of the container. Iterators and references to the last element, as well as the end() iterator, are invalidated. Complexity: constant.
|
inlinenoexcept |
Inserts and element before position. Complexity: linear in size().
| position | - where to insert the new element. |
| x | - element to insert. |
|
inlinenoexcept |
Inserts and element before position (r-value version). Complexity: linear in size().
| position | - where to insert the new element |
| x | - element to insert |
|
inlinenoexcept |
Inserts n copies of the value before pos Complexity: linear in size() and n.
| position | - where to insert the new elements. |
| n | - number of elements to insert. |
| x | - value of the elements to insert. |
|
inlinenoexcept |
Inserts a range of values via initializer list. Complexity: linear in size() and list.size().
| position | - where to insert the new elements. |
| list | - elements to insert. |
|
inlinenoexcept |
Inserts elements from range [first, last) before position. Complexity: linear in size() and distance(first, last).
| InputIt | - type of the input iterators. |
| position | - where to insert the new elements. |
| first | - range start. |
| last | - range end. |
|
inlinenoexcept |
Inserts elements from range [first, last) before position (by moving them). Complexity: linear in size() and distance(first, last).
| InputIt | - type of the input iterators. |
| position | - where to insert the new elements. |
| first | - range start. |
| last | - range end. |
|
inlinenoexcept |
Changes the size of the container to newSize. If need to be appended, elements are copy-constructed from value. Complexity: linear in newSize.
| newSize | - expected new size of the vector. |
| value | - to copy the new elements |
|
inlinenoexcept |
Changes the size of the container to newSize. If need to be appended, elements are move-constructed from T{}. Complexity: linear in newSize.
| newSize | - expected new size of the vector. |
|
inlinenoexcept |
Remove an element at position from the container. Complexity: linear in size().
Invalidates iterators and references at or after the point of the erase, including the end() iterator. / The iterator position must be valid and dereferenceable. Thus the end() iterator (which is valid, but is not dereferenceable) cannot be used as a value for position.
| position | - where to remove the element. |
|
inlinenoexcept |
Remove a range of elements from the container. Complexity: linear in size() and distance(first, last).
Invalidates iterators and references at or after the point of the erase, including the end() iterator. The iterator first does not need to be dereferenceable if first==last: erasing an empty range is a no-op.
| first | |
| last |
|
inlineprotectednoexcept |
Changes the container size to newSize.
|
inlinenoexcept |
|
staticconstexpr |
|
staticconstexpr |
|
staticconstexpr |
|
staticconstexpr |
|
staticconstexpr |
|
staticconstexpr |