Sen API
Sen Libraries
Loading...
Searching...
No Matches
sen::StaticVector< T, s > Class Template Reference

Stack-based, exception-free and resizable vector with fixed-capacity. More...

#include <static_vector.h>

Inheritance diagram for sen::StaticVector< T, s >:

Public Types

using Base = StaticVectorBase<T>
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

 StaticVector () noexcept
 Creates an empty vector.
 StaticVector (std::size_t n) noexcept
 Create a vector with n default-constructed elements. Complexity: linear in n.
 StaticVector (std::size_t n, T const &value) noexcept(Base::nothrowCopyCons)
 Create a vector with n copies of value. Complexity: linear in n.
 StaticVector (std::initializer_list< T > list) noexcept(Base::nothrowCopyCons)
 Create a vector from initializer list. Complexity: linear in list.size().
template<class InputIt>
 StaticVector (InputIt first, InputIt last) noexcept(Base::nothrowCopyCons)
 Create a vector from range [first, last). Complexity: linear in distance(first, last).
 StaticVector (const StaticVector &other) noexcept(Base::nothrowCopyCons)
 Copy constructor. Complexity: linear in other.size().
 StaticVector (StaticVector &&other) noexcept
 Move constructor.
 ~StaticVector () noexcept override=default
 Deletes all internal elements. Complexity: linear in size().
StaticVectoroperator= (const StaticVector &other) noexcept(Base::nothrowCopyCons)
 Copy assignment. Complexity: linear in other.size().
StaticVectoroperator= (StaticVector &&other) noexcept
 Move assignment.
void swap (StaticVector &other) noexcept
 Swaps the content of this vector with other. Complexity: linear in size() and x.size().
Basebase () noexcept
 This object, as its base class.
const Basebase () const noexcept
 This object, as its base class.
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 std::size_t staticCapacity = s
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

void internalSetSize (std::size_t newSize) noexcept
 Changes the container size to newSize.

Detailed Description

template<typename T, std::size_t s>
class sen::StaticVector< T, s >

Stack-based, exception-free 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 environments.

Note
This class is not thread-aware.
Template Parameters
Tvalue type.
smaximum size of the vector (capacity).

Member Typedef Documentation

◆ Base

template<typename T, std::size_t s>
using sen::StaticVector< T, s >::Base = StaticVectorBase<T>

◆ value_type

template<typename T>
using sen::StaticVectorBase< T >::value_type = T
inherited

◆ difference_type

template<typename T>
using sen::StaticVectorBase< T >::difference_type = ptrdiff_t
inherited

◆ pointer

template<typename T>
using sen::StaticVectorBase< T >::pointer = T*
inherited

◆ const_pointer

template<typename T>
using sen::StaticVectorBase< T >::const_pointer = T const*
inherited

◆ reference

template<typename T>
using sen::StaticVectorBase< T >::reference = T&
inherited

◆ const_reference

template<typename T>
using sen::StaticVectorBase< T >::const_reference = T const&
inherited

◆ rvalue_reference

template<typename T>
using sen::StaticVectorBase< T >::rvalue_reference = T&&
inherited

◆ iterator

template<typename T>
using sen::StaticVectorBase< T >::iterator = pointer
inherited

◆ const_iterator

template<typename T>
using sen::StaticVectorBase< T >::const_iterator = const_pointer
inherited

◆ size_type

template<typename T>
using sen::StaticVectorBase< T >::size_type = std::size_t
inherited

◆ reverse_iterator

template<typename T>
using sen::StaticVectorBase< T >::reverse_iterator = std::reverse_iterator<iterator>
inherited

◆ const_reverse_iterator

template<typename T>
using sen::StaticVectorBase< T >::const_reverse_iterator = std::reverse_iterator<const_iterator>
inherited

◆ Maybe

template<typename T>
using sen::StaticVectorBase< T >::Maybe = Result<void, StaticVectorError>
inherited

◆ MaybeIterator

template<typename T>
using sen::StaticVectorBase< T >::MaybeIterator = Result<iterator, StaticVectorError>
inherited

Constructor & Destructor Documentation

◆ StaticVector() [1/7]

template<typename T, std::size_t s>
sen::StaticVector< T, s >::StaticVector ( )
inlinenoexcept

Creates an empty vector.

◆ StaticVector() [2/7]

template<typename T, std::size_t c>
sen::StaticVector< T, c >::StaticVector ( std::size_t n)
inlineexplicitnoexcept

Create a vector with n default-constructed elements. Complexity: linear in n.

◆ StaticVector() [3/7]

template<typename T, std::size_t c>
sen::StaticVector< T, c >::StaticVector ( std::size_t n,
T const & value )
inlinenoexcept

Create a vector with n copies of value. Complexity: linear in n.

◆ StaticVector() [4/7]

template<typename T, std::size_t c>
sen::StaticVector< T, c >::StaticVector ( std::initializer_list< T > list)
inlinenoexcept

Create a vector from initializer list. Complexity: linear in list.size().

◆ StaticVector() [5/7]

template<typename T, std::size_t c>
template<class InputIt>
sen::StaticVector< T, c >::StaticVector ( InputIt first,
InputIt last )
inlinenoexcept

Create a vector from range [first, last). Complexity: linear in distance(first, last).

◆ StaticVector() [6/7]

template<typename T, std::size_t c>
sen::StaticVector< T, c >::StaticVector ( const StaticVector< T, s > & other)
inlinenoexcept

Copy constructor. Complexity: linear in other.size().

◆ StaticVector() [7/7]

template<typename T, std::size_t c>
sen::StaticVector< T, c >::StaticVector ( StaticVector< T, s > && other)
inlinenoexcept

Move constructor.

Postcondition
After the move, other is guaranteed to be empty(). Complexity: linear in other.size()

◆ ~StaticVector()

template<typename T, std::size_t s>
sen::StaticVector< T, s >::~StaticVector ( )
overridedefaultnoexcept

Deletes all internal elements. Complexity: linear in size().

Member Function Documentation

◆ operator=() [1/2]

template<typename T, std::size_t c>
StaticVector< T, c > & sen::StaticVector< T, c >::operator= ( const StaticVector< T, s > & other)
inlinenoexcept

Copy assignment. Complexity: linear in other.size().

◆ operator=() [2/2]

template<typename T, std::size_t c>
StaticVector< T, c > & sen::StaticVector< T, c >::operator= ( StaticVector< T, s > && other)
inlinenoexcept

Move assignment.

Postcondition
After the move, other is guaranteed to be empty(). Complexity: linear in other.size().

◆ swap()

template<typename T, std::size_t c>
void sen::StaticVector< T, c >::swap ( StaticVector< T, s > & other)
inlinenoexcept

Swaps the content of this vector with other. Complexity: linear in size() and x.size().

◆ base() [1/2]

template<typename T, std::size_t s>
Base & sen::StaticVector< T, s >::base ( )
inlinenodiscardnoexcept

This object, as its base class.

◆ base() [2/2]

template<typename T, std::size_t s>
const Base & sen::StaticVector< T, s >::base ( ) const
inlinenodiscardnoexcept

This object, as its base class.

◆ size()

template<typename T>
size_type sen::StaticVectorBase< T >::size ( ) const
inlinenodiscardnoexceptinherited

Element count. Complexity: constant.

◆ capacity()

template<typename T>
size_type sen::StaticVectorBase< T >::capacity ( ) const
inlinenodiscardnoexceptinherited

Maximum number of elements that can be allocated in the storage. Complexity: constant.

◆ maxSize()

template<typename T>
size_type sen::StaticVectorBase< T >::maxSize ( ) const
inlinenodiscardnoexceptinherited

Max element count (same as capacity()). Complexity: constant.

◆ data() [1/2]

template<typename T>
const_pointer sen::StaticVectorBase< T >::data ( ) const
inlinenodiscardnoexceptinherited

Direct access to the underlying storage. Complexity: constant.

◆ data() [2/2]

template<typename T>
pointer sen::StaticVectorBase< T >::data ( )
inlinenodiscardnoexceptinherited

Direct access to the underlying storage. Complexity: constant.

◆ empty()

template<typename T>
bool sen::StaticVectorBase< T >::empty ( ) const
inlinenodiscardnoexceptinherited

true if the container is empty. Complexity: constant

◆ full()

template<typename T>
bool sen::StaticVectorBase< T >::full ( ) const
inlinenodiscardnoexceptinherited

true if the container is full. Complexity: constant

◆ assign() [1/4]

template<typename T>
StaticVectorBase< T >::Maybe sen::StaticVectorBase< T >::assign ( StaticVectorBase< T >::size_type n,
const T & u )
inlinenodiscardnoexceptinherited

Clears the vector and assigns n copies of u to it. Complexity: linear in n.

Postcondition
object contains n values of u.
Parameters
nthe number of elements to assign.
uthe value to be copied in.
Returns
Ok - operation was successful full - not enough capacity to hold n elements.

◆ assign() [2/4]

template<typename T>
StaticVectorBase< T >::Maybe sen::StaticVectorBase< T >::assign ( const std::initializer_list< T > & list)
inlinenodiscardnoexceptinherited

Initializer list assignment. Complexity: linear in list.size().

Postcondition
object contains all the elements of list.
Parameters
listelements to be stored in the vector.
Returns
Ok - operation was successful full - not enough capacity to hold list.size() elements.

◆ assign() [3/4]

template<typename T>
StaticVectorBase< T >::Maybe sen::StaticVectorBase< T >::assign ( std::initializer_list< T > && list)
inlinenodiscardnoexceptinherited

Initializer list assignment (r-value version). Complexity: linear in list.size().

Postcondition
object contains all the elements of list.
Parameters
listelements to be stored in the vector.
Returns
Ok - operation was successful full - not enough capacity to hold list.size() elements.

◆ assign() [4/4]

template<typename T>
template<class InputIt>
StaticVectorBase< T >::Maybe sen::StaticVectorBase< T >::assign ( InputIt first,
InputIt last )
inlinenodiscardnoexceptinherited

Clears the vector and assigns a range to it. Complexity: linear in distance(first, last).

Postcondition
object contains a copy of all the elements between first and last.
Returns
Ok - operation was successful badRange - [first, last] is not a valid range. full - not enough capacity to hold list.size() elements.

◆ begin() [1/2]

template<typename T>
iterator sen::StaticVectorBase< T >::begin ( )
inlinenodiscardnoexceptinherited

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.

◆ begin() [2/2]

template<typename T>
const_iterator sen::StaticVectorBase< T >::begin ( ) const
inlinenodiscardnoexceptinherited

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.

◆ end() [1/2]

template<typename T>
iterator sen::StaticVectorBase< T >::end ( )
inlinenodiscardnoexceptinherited

Iterator to the element following the last element. Complexity: constant.

◆ end() [2/2]

template<typename T>
const_iterator sen::StaticVectorBase< T >::end ( ) const
inlinenodiscardnoexceptinherited

Iterator to the element following the last element. Complexity: constant. NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic).

◆ rbegin() [1/2]

template<typename T>
reverse_iterator sen::StaticVectorBase< T >::rbegin ( )
inlinenodiscardnoexceptinherited

Reverse iterator to the first element. Complexity: constant.

◆ rbegin() [2/2]

template<typename T>
const_reverse_iterator sen::StaticVectorBase< T >::rbegin ( ) const
inlinenodiscardnoexceptinherited

Reverse iterator to the first element. Complexity: constant.

◆ rend() [1/2]

template<typename T>
reverse_iterator sen::StaticVectorBase< T >::rend ( )
inlinenodiscardnoexceptinherited

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.

◆ rend() [2/2]

template<typename T>
const_reverse_iterator sen::StaticVectorBase< T >::rend ( ) const
inlinenodiscardnoexceptinherited

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.

◆ cbegin() [1/2]

template<typename T>
const_iterator sen::StaticVectorBase< T >::cbegin ( )
inlinenodiscardnoexceptinherited

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.

◆ cbegin() [2/2]

template<typename T>
const_iterator sen::StaticVectorBase< T >::cbegin ( ) const
inlinenodiscardnoexceptinherited

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.

◆ cend() [1/2]

template<typename T>
const_iterator sen::StaticVectorBase< T >::cend ( )
inlinenodiscardnoexceptinherited

Constant iterator to the element following the last element. Complexity: constant.

◆ cend() [2/2]

template<typename T>
const_iterator sen::StaticVectorBase< T >::cend ( ) const
inlinenodiscardnoexceptinherited

Constant iterator to the element following the last element. Complexity: constant.

◆ operator[]() [1/2]

template<typename T>
reference sen::StaticVectorBase< T >::operator[] ( size_type i)
inlinenodiscardnoexceptinherited

Gets the element at index i. Complexity: constant.

Precondition
i < size()
i >= 0
Warning
This function does not perform range checks. Please ensure that i is within valid limits.
Parameters
iindex of the element to fetch.
Returns
the value of the element at position i.

◆ operator[]() [2/2]

template<typename T>
const_reference sen::StaticVectorBase< T >::operator[] ( size_type i) const
inlinenodiscardnoexceptinherited

Gets the element at index i. Complexity: constant.

Precondition
i < size()
i >= 0
Warning
This function does not perform range checks. Please ensure that i is within valid limits.
Parameters
iindex of the element to fetch.
Returns
the value of the element at position i.

◆ front() [1/2]

template<typename T>
reference sen::StaticVectorBase< T >::front ( )
inlinenodiscardnoexceptinherited

The element at the beginning of the container. Calling front on an empty container is undefined. Complexity: constant.

Precondition
!empty()

◆ front() [2/2]

template<typename T>
const_reference sen::StaticVectorBase< T >::front ( ) const
inlinenodiscardnoexceptinherited

The element at the beginning of the container (const version). Calling front on an empty container is undefined. Complexity: constant.

Precondition
!empty()

◆ back() [1/2]

template<typename T>
reference sen::StaticVectorBase< T >::back ( )
inlinenodiscardnoexceptinherited

The element at the end of the container. Calling back on an empty container is undefined. Complexity: constant.

Precondition
!empty()

◆ back() [2/2]

template<typename T>
const_reference sen::StaticVectorBase< T >::back ( ) const
inlinenodiscardnoexceptinherited

The element at the end of the container (const version). Calling back on an empty container is undefined. Complexity: constant.

Precondition
!empty()

◆ clear()

template<typename T>
void sen::StaticVectorBase< T >::clear ( )
inlinenoexceptinherited

Clears the vector. This function destroys all the elements. Complexity: linear in size().

Postcondition
size() == 0
empty()

◆ push_back() [1/3]

template<typename T>
StaticVectorBase< T >::Maybe sen::StaticVectorBase< T >::push_back ( T && value)
inlinenoexceptinherited

Appends a value to the end of the container (r-value version). Complexity: constant.

Returns
Ok - operation was successful full - not enough capacity in the vector.

NOLINTNEXTLINE(readability-identifier-naming)

◆ push_back() [2/3]

template<typename T>
StaticVectorBase< T >::Maybe sen::StaticVectorBase< T >::push_back ( const T & value)
inlinenoexceptinherited

Appends a value to the end of the container. Complexity: constant.

Returns
Ok - operation was successful full - not enough capacity in the vector.

NOLINTNEXTLINE(readability-identifier-naming)

◆ push_back() [3/3]

template<typename T>
StaticVectorBase< T >::Maybe sen::StaticVectorBase< T >::push_back ( )
inlinenoexceptinherited

Appends a value (default constructed) to the end of the container. Complexity: constant.

Returns
Ok - operation was successful full - not enough capacity in the vector.

NOLINTNEXTLINE(readability-identifier-naming)

◆ emplace()

template<typename T>
template<typename... Args>
StaticVectorBase< T >::MaybeIterator sen::StaticVectorBase< T >::emplace ( StaticVectorBase< T >::iterator position,
Args &&... args )
inlinenoexceptinherited

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().

Returns
badRange - position was not in a valid range full - not enough capacity in the vector. iterator - pointing to the emplaced element.

◆ emplace_back()

template<typename T>
template<typename... Args>
StaticVectorBase< T >::Maybe sen::StaticVectorBase< T >::emplace_back ( Args &&... args)
inlinenoexceptinherited

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

Template Parameters
Args- arguments for constructing the element.
Returns
full - not enough capacity in the vector. iterator - pointing to the emplaced element.

◆ pop_back()

template<typename T>
StaticVectorBase< T >::Maybe sen::StaticVectorBase< T >::pop_back ( )
inlinenoexceptinherited

Removes the last element of the container. Iterators and references to the last element, as well as the end() iterator, are invalidated. Complexity: constant.

Returns
empty - attempted to pop_back on an empty vector. ok - successful operation.

◆ insert() [1/5]

template<typename T>
StaticVectorBase< T >::MaybeIterator sen::StaticVectorBase< T >::insert ( StaticVectorBase< T >::iterator position,
const_reference x )
inlinenoexceptinherited

Inserts and element before position. Complexity: linear in size().

Parameters
position- where to insert the new element.
x- element to insert.
Returns
badRange - position was not in a valid range. full - not enough capacity in the vector. iterator - pointing to the inserted element.

◆ insert() [2/5]

template<typename T>
StaticVectorBase< T >::MaybeIterator sen::StaticVectorBase< T >::insert ( iterator position,
value_type && x )
inlinenoexceptinherited

Inserts and element before position (r-value version). Complexity: linear in size().

Parameters
position- where to insert the new element
x- element to insert
Returns
badRange - position was not in a valid range. full - not enough capacity in the vector. iterator - pointing to the inserted element.

◆ insert() [3/5]

template<typename T>
StaticVectorBase< T >::MaybeIterator sen::StaticVectorBase< T >::insert ( StaticVectorBase< T >::iterator position,
StaticVectorBase< T >::size_type n,
const T & x )
inlinenoexceptinherited

Inserts n copies of the value before pos Complexity: linear in size() and n.

Parameters
position- where to insert the new elements.
n- number of elements to insert.
x- value of the elements to insert.
Returns
badRange - position was not in a valid range. full - not enough capacity in the vector. iterator - iterator pointing to the first element inserted, or position if n == 0.

◆ insert() [4/5]

template<typename T>
StaticVectorBase< T >::MaybeIterator sen::StaticVectorBase< T >::insert ( StaticVectorBase< T >::iterator position,
std::initializer_list< T > list )
inlinenoexceptinherited

Inserts a range of values via initializer list. Complexity: linear in size() and list.size().

Parameters
position- where to insert the new elements.
list- elements to insert.
Returns
badRange - position was not in a valid range. full - not enough capacity in the vector. iterator - iterator pointing to the first element inserted, or position if list.size() == 0.

◆ insert() [5/5]

template<typename T>
template<class InputIt>
StaticVectorBase< T >::MaybeIterator sen::StaticVectorBase< T >::insert ( iterator position,
InputIt first,
InputIt last )
inlinenoexceptinherited

Inserts elements from range [first, last) before position. Complexity: linear in size() and distance(first, last).

Template Parameters
InputIt- type of the input iterators.
Parameters
position- where to insert the new elements.
first- range start.
last- range end.
Returns
badRange - [first, last) is not a valid range. full - not enough capacity in the vector. iterator - iterator pointing to the first element inserted, or position if first == last.

◆ move_insert()

template<typename T>
template<class InputIt>
StaticVectorBase< T >::MaybeIterator sen::StaticVectorBase< T >::move_insert ( iterator position,
InputIt first,
InputIt last )
inlinenoexceptinherited

Inserts elements from range [first, last) before position (by moving them). Complexity: linear in size() and distance(first, last).

Template Parameters
InputIt- type of the input iterators.
Parameters
position- where to insert the new elements.
first- range start.
last- range end.
Returns
badRange - [first, last) is not a valid range. full - not enough capacity in the vector. iterator - iterator pointing to the first element inserted, or position if first == last.

◆ resize() [1/2]

template<typename T>
StaticVectorBase< T >::Maybe sen::StaticVectorBase< T >::resize ( StaticVectorBase< T >::size_type newSize,
const T & value )
inlinenoexceptinherited

Changes the size of the container to newSize. If need to be appended, elements are copy-constructed from value. Complexity: linear in newSize.

Parameters
newSize- expected new size of the vector.
value- to copy the new elements
Returns
full - not enough capacity in the vector. ok - successful operation.

◆ resize() [2/2]

template<typename T>
StaticVectorBase< T >::Maybe sen::StaticVectorBase< T >::resize ( StaticVectorBase< T >::size_type newSize)
inlinenoexceptinherited

Changes the size of the container to newSize. If need to be appended, elements are move-constructed from T{}. Complexity: linear in newSize.

Parameters
newSize- expected new size of the vector.
Returns
full - not enough capacity in the vector. ok - successful operation.

◆ erase() [1/2]

template<typename T>
StaticVectorBase< T >::MaybeIterator sen::StaticVectorBase< T >::erase ( StaticVectorBase< T >::iterator position)
inlinenoexceptinherited

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.

Parameters
position- where to remove the element.
Returns
badRange - position is not in a valid range. iterator - Iterator following the last removed element. If position refers to the last element, then the end() iterator is returned.

◆ erase() [2/2]

template<typename T>
StaticVectorBase< T >::MaybeIterator sen::StaticVectorBase< T >::erase ( StaticVectorBase< T >::iterator first,
StaticVectorBase< T >::iterator last )
inlinenoexceptinherited

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.

Parameters
first
last
Returns
badRange - first, last is not a valid range. iterator - iterator following the last removed element. if [first, last) is an empty range, then last is returned.

◆ internalDestroy()

template<typename T>
template<class InputIt>
void sen::StaticVectorBase< T >::internalDestroy ( InputIt first,
InputIt last )
inlinenoexceptinherited

◆ internalSetSize()

template<typename T>
void sen::StaticVectorBase< T >::internalSetSize ( std::size_t newSize)
inlineprotectednoexceptinherited

Changes the container size to newSize.

Precondition
: newSize <= capacity().
Note
No elements are constructed or destroyed. Complexity: constant

Member Data Documentation

◆ staticCapacity

template<typename T, std::size_t s>
std::size_t sen::StaticVector< T, s >::staticCapacity = s
staticconstexpr

◆ nothrowDes

template<typename T>
bool sen::StaticVectorBase< T >::nothrowDes = std::is_nothrow_destructible_v<T>
staticconstexprinherited

◆ nothrowDefaultCons

template<typename T>
bool sen::StaticVectorBase< T >::nothrowDefaultCons = std::is_nothrow_default_constructible_v<T>
staticconstexprinherited

◆ nothrowCopyCons

template<typename T>
bool sen::StaticVectorBase< T >::nothrowCopyCons = std::is_nothrow_copy_constructible_v<T>
staticconstexprinherited

◆ nothrowMoveCons

template<typename T>
bool sen::StaticVectorBase< T >::nothrowMoveCons = std::is_nothrow_move_constructible_v<T>
staticconstexprinherited

◆ nothrowCopyAndDes

template<typename T>
bool sen::StaticVectorBase< T >::nothrowCopyAndDes = nothrowDes && nothrowCopyCons
staticconstexprinherited

◆ nothrowDefaultConsAndDes

template<typename T>
bool sen::StaticVectorBase< T >::nothrowDefaultConsAndDes = nothrowDefaultCons && nothrowDes
staticconstexprinherited

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