Arene Base
Fundamental Utilities For Safety Critical C++
Loading...
Searching...
No Matches
arene::base::inline_vector< T, Capacity > Class Template Reference

A container similar to std::vector<T> that has a fixed capacity. The storage for the elements is held directly within the class. Any attempt to store more than Capacity elements will throw std::length_error. More...

Inheritance diagram for arene::base::inline_vector< T, Capacity >:
Inheritance graph

Public Member Functions

constexpr inline_vector ()=default
 Construct an empty vector.
 
constexpr inline_vector (inline_vector &&)=default
 Default move constructor.
 
constexpr inline_vector (inline_vector const &)=default
 Default copy constructor.
 
template<size_type OtherCapacity, constraints< std::enable_if_t< OtherCapacity !=Capacity > > = nullptr>
constexpr inline_vector (inline_vector< T, OtherCapacity > &&other) noexcept(std::is_nothrow_move_constructible< T >::value)
 Move construct from a vector with a different capacity.
 
template<size_type OtherCapacity, typename U = T, constraints< std::enable_if_t< std::is_same< U, T >::value >, std::enable_if_t< std::is_copy_constructible< U >::value >, std::enable_if_t< OtherCapacity !=Capacity > > = nullptr>
constexpr inline_vector (inline_vector< T, OtherCapacity > const &other) noexcept(std::is_nothrow_copy_constructible< T >::value)
 Copy construct from a vector with a different capacity.
 
 ~inline_vector ()=default
 Default destructor.
 
constexpr auto operator= (inline_vector &&) -> inline_vector &=default
 Default move assignment.
 
constexpr auto operator= (inline_vector const &) -> inline_vector &=default
 Default copy assignment.
 
template<size_type OtherCapacity, constraints< std::enable_if_t< OtherCapacity !=Capacity > > = nullptr>
auto operator= (inline_vector< T, OtherCapacity > &&other) noexcept(std::is_nothrow_move_constructible< T >::value &&std::is_nothrow_move_assignable< T >::value) -> inline_vector &
 Move-assign to the vector from the elements of a vector with a different capacity. Assigns over existing elements, constructs additional elements, and destroys any excess.
 
template<typename U = T, size_type OtherCapacity, constraints< std::enable_if_t< OtherCapacity !=Capacity >, std::enable_if_t< std::is_copy_constructible< U >::value >, std::enable_if_t< std::is_copy_assignable< U >::value > > = nullptr>
auto operator= (inline_vector< U, OtherCapacity > const &other) noexcept(std::is_nothrow_copy_constructible< U >::value &&std::is_nothrow_copy_assignable< U >::value) -> inline_vector &
 Copy-assign to the vector from the elements of a vector with a different capacity. Assigns over existing elements, constructs additional elements, and destroys any excess.
 
auto operator= (std::initializer_list< T > source_values) noexcept(std::is_nothrow_copy_constructible< T >::value &&std::is_nothrow_copy_assignable< T >::value) -> inline_vector &
 Assign to the vector from the elements of an initializer list. Assigns over existing elements, constructs additional elements, and destroys any excess.
 
template<typename U = value_type, constraints< std::enable_if_t< is_swappable_v< U > > > = nullptr>
constexpr void swap (inline_vector &other) noexcept(is_nothrow_swappable_v< value_type > &&std::is_nothrow_move_constructible< value_type >::value)
 swaps all the elements between this vector and another.
 

Static Public Member Functions

static constexpr auto try_construct () noexcept -> optional< inline_vector >
 Default construct a vector.
 
template<typename Container, constraints< std::enable_if_t< std::is_constructible< inline_vector, Container && >::value >, std::enable_if_t< inline_vector_detail::is_inline_vector_of_t_v< T, Container > > > = nullptr>
static constexpr auto try_construct (Container &&container) noexcept(std::is_nothrow_constructible< inline_vector, Container && >::value) -> optional< inline_vector >
 Construct a vector initialized with the specified paramters.
 
template<typename Container, constraints< std::enable_if_t< std::is_constructible< inline_vector, Container const & >::value >, std::enable_if_t< inline_vector_detail::is_inline_vector_of_t_v< T, Container > > > = nullptr>
static constexpr auto try_construct (Container const &container) noexcept(std::is_nothrow_constructible< inline_vector, Container const & >::value) -> optional< inline_vector >
 Construct a vector initialized with the specified paramters.
 
template<typename Iterator, typename U = T, constraints< std::enable_if_t< is_bidirectional_iterator_v< Iterator > >, std::enable_if_t< std::is_same< U, T >::value >, std::enable_if_t< std::is_constructible< U, typename std::iterator_traits< Iterator >::reference >::value > > = nullptr>
static constexpr auto try_construct (Iterator first, Iterator last) noexcept(denotes_nothrow_iterable_range_v< Iterator > &&std::is_nothrow_constructible< T, typename std::iterator_traits< Iterator >::reference >::value) -> optional< inline_vector >
 Construct a vector from a bidrectional iterator range.
 
template<typename Iterator, typename U = T, constraints< std::enable_if_t< is_input_iterator_v< Iterator > >, std::enable_if_t<!is_bidirectional_iterator_v< Iterator > >, std::enable_if_t< std::is_same< U, T >::value >, std::enable_if_t< std::is_constructible< U, typename std::iterator_traits< Iterator >::reference >::value > > = nullptr>
static constexpr auto try_construct (Iterator first, Iterator last) noexcept(denotes_nothrow_iterable_range_v< Iterator > &&std::is_nothrow_constructible< T, typename std::iterator_traits< Iterator >::reference >::value) -> optional< inline_vector >
 Construct a vector from an input iterator range.
 
template<typename U = T, constraints< std::enable_if_t< std::is_same< U, T >::value >, std::enable_if_t< std::is_default_constructible< U >::value > > = nullptr>
static constexpr auto try_construct (size_type count) noexcept(std::is_nothrow_default_constructible< T >::value) -> optional< inline_vector >
 Construct a vector with the specified number of default-constructed elements.
 
template<typename U = T, constraints< std::enable_if_t< std::is_same< U, T >::value >, std::enable_if_t< std::is_copy_constructible< U >::value > > = nullptr>
static constexpr auto try_construct (size_type count, T const &source) noexcept(std::is_nothrow_copy_constructible< T >::value) -> optional< inline_vector >
 Construct a vector with the specified number of elements copied from the provided source.
 
template<typename InitElement, constraints< std::enable_if_t< std::is_constructible< inline_vector, typename std::initializer_list< InitElement >::const_iterator, typename std::initializer_list< InitElement >::const_iterator >::value > > = nullptr>
static constexpr auto try_construct (std::initializer_list< InitElement > const &init_list) noexcept(std::is_nothrow_constructible< inline_vector, typename std::initializer_list< InitElement >::const_iterator, typename std::initializer_list< InitElement >::const_iterator >::value) -> optional< inline_vector >
 Construct a vector initialized with the specified parameters.
 

Friends

template<typename U = value_type, constraints< std::enable_if_t< is_less_than_comparable_v< U > > > = nullptr>
constexpr auto operator< (inline_vector const &lhs, inline_vector const &rhs) noexcept -> bool
 Compare two vectors for lexicographical ordering.
 
template<typename U = value_type, constraints< std::enable_if_t< is_equality_comparable_v< U > > > = nullptr>
constexpr auto operator== (inline_vector const &lhs, inline_vector const &rhs) noexcept -> bool
 Compare two vectors for equality.
 
template<typename U = value_type, constraints< std::enable_if_t< is_swappable_v< U > > > = nullptr>
constexpr void swap (inline_vector &lhs, inline_vector &rhs) noexcept(noexcept(lhs.swap(rhs)))
 swaps all the elements between two vectors.
 

Detailed Description

template<typename T, std::size_t Capacity>
class arene::base::inline_vector< T, Capacity >

A container similar to std::vector<T> that has a fixed capacity. The storage for the elements is held directly within the class. Any attempt to store more than Capacity elements will throw std::length_error.

Template Parameters
TThe type of each element
CapacityThe maximum number of elements that can be stored.

Constructor & Destructor Documentation

◆ inline_vector() [1/5]

template<typename T, std::size_t Capacity>
arene::base::inline_vector< T, Capacity >::inline_vector ( )
constexprdefault

Construct an empty vector.

◆ ~inline_vector()

template<typename T, std::size_t Capacity>
arene::base::inline_vector< T, Capacity >::~inline_vector ( )
default

Default destructor.

◆ inline_vector() [2/5]

template<typename T, std::size_t Capacity>
template<size_type OtherCapacity, typename U = T, constraints< std::enable_if_t< std::is_same< U, T >::value >, std::enable_if_t< std::is_copy_constructible< U >::value >, std::enable_if_t< OtherCapacity !=Capacity > > = nullptr>
arene::base::inline_vector< T, Capacity >::inline_vector ( inline_vector< T, OtherCapacity > const & other)
inlineexplicitconstexprnoexcept

Copy construct from a vector with a different capacity.

Template Parameters
OtherCapacityThe capacity of the other vector
UDummy template parameter the same as T for constraints
Parameters
otherThe other vector
Precondition
other.size()<=capacity(), else ARENE_PRECONDITION violation

◆ inline_vector() [3/5]

template<typename T, std::size_t Capacity>
template<size_type OtherCapacity, constraints< std::enable_if_t< OtherCapacity !=Capacity > > = nullptr>
arene::base::inline_vector< T, Capacity >::inline_vector ( inline_vector< T, OtherCapacity > && other)
inlineexplicitconstexprnoexcept

Move construct from a vector with a different capacity.

Template Parameters
OtherCapacityThe capacity of the other vector
Parameters
otherThe other vector
Precondition
other.size()<=Capacity, else ARENE_PRECONDITION violation

◆ inline_vector() [4/5]

template<typename T, std::size_t Capacity>
arene::base::inline_vector< T, Capacity >::inline_vector ( inline_vector< T, Capacity > const & )
constexprdefault

Default copy constructor.

◆ inline_vector() [5/5]

template<typename T, std::size_t Capacity>
arene::base::inline_vector< T, Capacity >::inline_vector ( inline_vector< T, Capacity > && )
constexprdefault

Default move constructor.

Member Function Documentation

◆ operator=() [1/5]

template<typename T, std::size_t Capacity>
auto arene::base::inline_vector< T, Capacity >::operator= ( inline_vector< T, Capacity > && ) -> inline_vector &=default
constexprdefault

Default move assignment.

◆ operator=() [2/5]

template<typename T, std::size_t Capacity>
auto arene::base::inline_vector< T, Capacity >::operator= ( inline_vector< T, Capacity > const & ) -> inline_vector &=default
constexprdefault

Default copy assignment.

◆ operator=() [3/5]

template<typename T, std::size_t Capacity>
template<size_type OtherCapacity, constraints< std::enable_if_t< OtherCapacity !=Capacity > > = nullptr>
auto arene::base::inline_vector< T, Capacity >::operator= ( inline_vector< T, OtherCapacity > && other) -> inline_vector&
inlinenoexcept

Move-assign to the vector from the elements of a vector with a different capacity. Assigns over existing elements, constructs additional elements, and destroys any excess.

Parameters
otherThe source vector
Precondition
other.size()<=Capacity, else ARENE_PRECONDITION violation

◆ operator=() [4/5]

template<typename T, std::size_t Capacity>
template<typename U = T, size_type OtherCapacity, constraints< std::enable_if_t< OtherCapacity !=Capacity >, std::enable_if_t< std::is_copy_constructible< U >::value >, std::enable_if_t< std::is_copy_assignable< U >::value > > = nullptr>
auto arene::base::inline_vector< T, Capacity >::operator= ( inline_vector< U, OtherCapacity > const & other) -> inline_vector&
inlinenoexcept

Copy-assign to the vector from the elements of a vector with a different capacity. Assigns over existing elements, constructs additional elements, and destroys any excess.

Parameters
otherThe source vector
Precondition
other.size()<=Capacity, else ARENE_PRECONDITION violation

◆ operator=() [5/5]

template<typename T, std::size_t Capacity>
auto arene::base::inline_vector< T, Capacity >::operator= ( std::initializer_list< T > source_values) -> inline_vector&
inlinenoexcept

Assign to the vector from the elements of an initializer list. Assigns over existing elements, constructs additional elements, and destroys any excess.

Parameters
source_valuesThe source values
Precondition
source_values.size()<=Capacity, else ARENE_PRECONDITION violation

◆ swap()

template<typename T, std::size_t Capacity>
template<typename U = value_type, constraints< std::enable_if_t< is_swappable_v< U > > > = nullptr>
void arene::base::inline_vector< T, Capacity >::swap ( inline_vector< T, Capacity > & other)
inlineconstexprnoexcept

swaps all the elements between this vector and another.

Template Parameters
Uthe type of the elements in the array. Must satisfy is_swappable_v .
Parameters
otherthe vector to swap with.
Postcondition
The elements in this and other are exchanged 1:1 up to the size() of the smallest vector. Relative order is maintained. The remaining elements from the originally larger vector are move-constructed into the originally smaller vector maintaining relative order, and the elements in the originally larger vector are destroyed.

◆ try_construct() [1/8]

template<typename T, std::size_t Capacity>
static constexpr auto arene::base::inline_vector< T, Capacity >::try_construct ( ) -> optional<inline_vector>
inlinestaticconstexprnoexcept

Default construct a vector.

Returns
optional<inline_vector> holding the default-constructed vector

◆ try_construct() [2/8]

template<typename T, std::size_t Capacity>
template<typename Container, constraints< std::enable_if_t< std::is_constructible< inline_vector, Container && >::value >, std::enable_if_t< inline_vector_detail::is_inline_vector_of_t_v< T, Container > > > = nullptr>
static constexpr auto arene::base::inline_vector< T, Capacity >::try_construct ( Container && container) -> optional<inline_vector>
inlinestaticconstexprnoexcept

Construct a vector initialized with the specified paramters.

Template Parameters
ContainerThe type of the container with which to initialize the vector
Parameters
containerThe container with which to initialize the vector
Returns
optional<inline_vector> holding the vector if the number of elements in the source container is less than or equal to the Capacity, otherwise returns an empty optional

◆ try_construct() [3/8]

template<typename T, std::size_t Capacity>
template<typename Container, constraints< std::enable_if_t< std::is_constructible< inline_vector, Container const & >::value >, std::enable_if_t< inline_vector_detail::is_inline_vector_of_t_v< T, Container > > > = nullptr>
static constexpr auto arene::base::inline_vector< T, Capacity >::try_construct ( Container const & container) -> optional<inline_vector>
inlinestaticconstexprnoexcept

Construct a vector initialized with the specified paramters.

Template Parameters
ContainerThe type of the container with which to initialize the vector
Parameters
containerThe container with which to initialize the vector
Returns
optional<inline_vector> holding the vector if the number of elements in the source container is less than or equal to the Capacity, otherwise returns an empty optional

◆ try_construct() [4/8]

template<typename T, std::size_t Capacity>
template<typename Iterator, typename U = T, constraints< std::enable_if_t< is_bidirectional_iterator_v< Iterator > >, std::enable_if_t< std::is_same< U, T >::value >, std::enable_if_t< std::is_constructible< U, typename std::iterator_traits< Iterator >::reference >::value > > = nullptr>
static constexpr auto arene::base::inline_vector< T, Capacity >::try_construct ( Iterator first,
Iterator last ) -> optional<inline_vector>
inlinestaticconstexprnoexcept

Construct a vector from a bidrectional iterator range.

Template Parameters
IteratorThe type of the iterator
UDummy template parameter the same as T for constraints
Parameters
firstThe start of the range
lastThe end of the range
Returns
optional<inline_vector> holding the resulting vector if the number of elements in the range is less than or equal to Capacity, an empty optional otherwise

◆ try_construct() [5/8]

template<typename T, std::size_t Capacity>
template<typename Iterator, typename U = T, constraints< std::enable_if_t< is_input_iterator_v< Iterator > >, std::enable_if_t<!is_bidirectional_iterator_v< Iterator > >, std::enable_if_t< std::is_same< U, T >::value >, std::enable_if_t< std::is_constructible< U, typename std::iterator_traits< Iterator >::reference >::value > > = nullptr>
static constexpr auto arene::base::inline_vector< T, Capacity >::try_construct ( Iterator first,
Iterator last ) -> optional<inline_vector>
inlinestaticconstexprnoexcept

Construct a vector from an input iterator range.

Template Parameters
IteratorThe type of the iterator
UDummy template parameter the same as T for constraints
Parameters
firstThe start of the range
lastThe end of the range
Returns
optional<inline_vector> holding the resulting vector if the number of elements in the range is less than or equal to Capacity, an empty optional otherwise

◆ try_construct() [6/8]

template<typename T, std::size_t Capacity>
template<typename U = T, constraints< std::enable_if_t< std::is_same< U, T >::value >, std::enable_if_t< std::is_default_constructible< U >::value > > = nullptr>
static constexpr auto arene::base::inline_vector< T, Capacity >::try_construct ( size_type count) -> optional<inline_vector>
inlinestaticconstexprnoexcept

Construct a vector with the specified number of default-constructed elements.

Template Parameters
UDummy template parameter the same as T for constraints
Parameters
countThe number of elements to construct in the vector
Returns
optional<inline_vector> holding the vector if the count is less than or equal to the Capacity, otherwise returns an empty optional

◆ try_construct() [7/8]

template<typename T, std::size_t Capacity>
template<typename U = T, constraints< std::enable_if_t< std::is_same< U, T >::value >, std::enable_if_t< std::is_copy_constructible< U >::value > > = nullptr>
static constexpr auto arene::base::inline_vector< T, Capacity >::try_construct ( size_type count,
T const & source ) -> optional<inline_vector>
inlinestaticconstexprnoexcept

Construct a vector with the specified number of elements copied from the provided source.

Template Parameters
UDummy template parameter the same as T for constraints
Parameters
countThe number of elements to construct in the vector
sourceThe element to copy
Returns
optional<inline_vector> holding the vector if the count is less than or equal to the Capacity, otherwise returns an empty optional

◆ try_construct() [8/8]

template<typename T, std::size_t Capacity>
template<typename InitElement, constraints< std::enable_if_t< std::is_constructible< inline_vector, typename std::initializer_list< InitElement >::const_iterator, typename std::initializer_list< InitElement >::const_iterator >::value > > = nullptr>
static constexpr auto arene::base::inline_vector< T, Capacity >::try_construct ( std::initializer_list< InitElement > const & init_list) -> optional<inline_vector>
inlinestaticconstexprnoexcept

Construct a vector initialized with the specified parameters.

Template Parameters
InitElementThe type of the elements in the initializer list with which to initialize the vector
Parameters
init_listThe initializer list with which to initialize the vector
Returns
optional<inline_vector> holding the vector if the number of elements in the source container is less than or equal to the Capacity, otherwise returns an empty optional

Friends And Related Symbol Documentation

◆ operator<

template<typename T, std::size_t Capacity>
template<typename U = value_type, constraints< std::enable_if_t< is_less_than_comparable_v< U > > > = nullptr>
auto operator< ( inline_vector< T, Capacity > const & lhs,
inline_vector< T, Capacity > const & rhs ) -> bool
friend

Compare two vectors for lexicographical ordering.

Template Parameters
Udummy parameter to disable if value_type is not less-than-comparable
Parameters
lhsThe first vector
rhsThe second vector
Returns
bool equivalent to arene::base::lexicographical_compare(lhs.begin(),lhs.end(),rhs.begin(),rhs.end()) .

◆ operator==

template<typename T, std::size_t Capacity>
template<typename U = value_type, constraints< std::enable_if_t< is_equality_comparable_v< U > > > = nullptr>
auto operator== ( inline_vector< T, Capacity > const & lhs,
inline_vector< T, Capacity > const & rhs ) -> bool
friend

Compare two vectors for equality.

Template Parameters
Udummy parameter to disable if value_type is three-way-comparable
Parameters
lhsThe first vector
rhsThe second vector
Returns
bool equivalent to arene::base::equal(lhs.begin(),lhs.end(),rhs.begin(),rhs.end()) .

◆ swap

template<typename T, std::size_t Capacity>
template<typename U = value_type, constraints< std::enable_if_t< is_swappable_v< U > > > = nullptr>
void swap ( inline_vector< T, Capacity > & lhs,
inline_vector< T, Capacity > & rhs )
friend

swaps all the elements between two vectors.

Template Parameters
Uthe type of the elements in the vector. Must satisfy is_swappable_v .
Parameters
lhsthe left hand vector to swap.
rhsthe right hand vector to swap.
Postcondition
Equivalent to having called lhs.swap(rhs);
See also
inline_vector::swap.

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