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

A reference class to an inline_vector object, with size-erased type. More...

Public Types

using const_iterator = typename inline_vector_detail::vector_base<T>::const_iterator
 The const iterator type of the underlying vector.
 
using iterator = typename inline_vector_detail::vector_base<T>::iterator
 The iterator type of the underlying vector.
 
using size_type = std::size_t
 The size type.
 
using value_type = T
 The value type.
 

Public Member Functions

constexpr vector_reference (external_vector< T > &vec)
 Construct a vector reference to the supplied external_vector.
 
template<std::size_t Capacity>
constexpr vector_reference (inline_vector< T, Capacity > &vec)
 Construct a vector reference to the supplied inline_vector.
 
template<bool AreExceptionsEnabled = detail::are_exceptions_enabled::value, constraints< std::enable_if_t< AreExceptionsEnabled > > = nullptr>
constexpr auto at (size_type index) const -> T &
 Obtain a const reference to the element with the specified index.
 
constexpr auto back () const noexcept -> T &
 Get a const reference to the last element.
 
constexpr auto begin () const noexcept -> iterator
 Obtain a const iterator to the start of the vector.
 
constexpr auto capacity () const noexcept -> size_type
 Get the capacity.
 
constexpr auto cbegin () const noexcept -> const_iterator
 Obtain an const iterator to the start of the vector.
 
constexpr auto cend () const noexcept -> const_iterator
 Obtain a const iterator to the end of the vector.
 
constexpr void clear () const noexcept
 Destroy all elements and set the size to zero.
 
constexpr auto const_operations_ptr (vector_reference_detail::ivref_passkey) const noexcept -> vector_reference_detail::const_operations< T > const *
 Get a pointer to the struct holding const operation implementations.
 
constexpr auto data () const noexcept -> T *
 Obtain a pointer to the stored elements.
 
constexpr auto empty () const noexcept -> bool
 Check if the vector is empty.
 
constexpr auto end () const noexcept -> iterator
 Obtain a const iterator to the end of the vector.
 
constexpr auto erase (const_iterator first, const_iterator last) const noexcept -> iterator
 Erase all the element in the specified range.
 
constexpr auto erase (const_iterator iter) const noexcept -> iterator
 Erase the element at the specified position.
 
constexpr auto front () const noexcept -> T &
 Get a const reference to the first element.
 
constexpr auto get_vector_ptr (vector_reference_detail::ivref_passkey) const noexcept -> inline_vector_detail::vector_base< T > *
 Get a pointer to the underlying vector object.
 
template<typename InputIterator>
constexpr auto insert (const_iterator pos, InputIterator first, InputIterator last) const -> iterator
 Insert a range of elements at the specified position.
 
constexpr auto insert (const_iterator pos, T const &value) const noexcept -> iterator
 Insert a new element at the specified position in the vector by copy-constructing or copy-assigning from the supplied value. Any existing elements from the specified position to the end of the vector are moved to make room.
 
constexpr auto max_size () const noexcept -> size_type
 Check if the vector is empty.
 
constexpr auto operator[] (size_type index) const noexcept -> T &
 Obtain a const reference to the element with the specified index.
 
constexpr void pop_back () const noexcept
 Destroy the last element in the vector and decrease the size.
 
constexpr void push_back (T const &element) const noexcept
 Add a new element to the end of the vector as a copy of the supplied value.
 
constexpr void resize (size_type count) const
 Resize the vector to the specified size. Default-constructs any missing elements, and destroys any excess.
 
constexpr auto size () const noexcept -> size_type
 Get the current number of live elements in the vector.
 

Detailed Description

template<typename T>
class arene::base::vector_reference< T >

A reference class to an inline_vector object, with size-erased type.

Template Parameters
TThe type of each element

Member Typedef Documentation

◆ const_iterator

template<typename T>
using arene::base::vector_reference< T >::const_iterator = typename inline_vector_detail::vector_base<T>::const_iterator

The const iterator type of the underlying vector.

◆ iterator

template<typename T>
using arene::base::vector_reference< T >::iterator = typename inline_vector_detail::vector_base<T>::iterator

The iterator type of the underlying vector.

◆ size_type

template<typename T>
using arene::base::vector_reference< T >::size_type = std::size_t

The size type.

◆ value_type

template<typename T>
using arene::base::vector_reference< T >::value_type = T

The value type.

Constructor & Destructor Documentation

◆ vector_reference() [1/2]

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

Construct a vector reference to the supplied inline_vector.

Template Parameters
CapacityThe maximum number of elements that can be stored
Parameters
vecThe inline_vector to reference

◆ vector_reference() [2/2]

template<typename T>
arene::base::vector_reference< T >::vector_reference ( external_vector< T > & vec)
inlineexplicitconstexpr

Construct a vector reference to the supplied external_vector.

Parameters
vecThe external_vector to reference

Member Function Documentation

◆ at()

template<typename T>
template<bool AreExceptionsEnabled = detail::are_exceptions_enabled::value, constraints< std::enable_if_t< AreExceptionsEnabled > > = nullptr>
auto arene::base::vector_reference< T >::at ( size_type index) const -> T&
inlineconstexpr

Obtain a const reference to the element with the specified index.

Template Parameters
AreExceptionsEnabledUsed to disable this overload if exceptions are not enabled.
Parameters
indexThe index of the element
Returns
A reference to the element
Exceptions
std::out_of_rangeif the index is out of range

◆ back()

template<typename T>
auto arene::base::vector_reference< T >::back ( ) const -> T&
inlineconstexprnoexcept

Get a const reference to the last element.

Returns
A reference to the element
Precondition
The vector must not be empty

◆ begin()

template<typename T>
auto arene::base::vector_reference< T >::begin ( ) const -> iterator
inlineconstexprnoexcept

Obtain a const iterator to the start of the vector.

Returns
The iterator

◆ capacity()

template<typename T>
auto arene::base::vector_reference< T >::capacity ( ) const -> size_type
inlineconstexprnoexcept

Get the capacity.

Returns
the capacity

◆ cbegin()

template<typename T>
auto arene::base::vector_reference< T >::cbegin ( ) const -> const_iterator
inlineconstexprnoexcept

Obtain an const iterator to the start of the vector.

Returns
The iterator

◆ cend()

template<typename T>
auto arene::base::vector_reference< T >::cend ( ) const -> const_iterator
inlineconstexprnoexcept

Obtain a const iterator to the end of the vector.

Returns
The iterator

◆ clear()

template<typename T>
void arene::base::vector_reference< T >::clear ( ) const
inlineconstexprnoexcept

Destroy all elements and set the size to zero.

◆ const_operations_ptr()

template<typename T>
auto arene::base::vector_reference< T >::const_operations_ptr ( vector_reference_detail::ivref_passkey ) const -> vector_reference_detail::const_operations<T> const*
inlineconstexprnoexcept

Get a pointer to the struct holding const operation implementations.

Returns
A pointer to the struct holding const operation implementations

◆ data()

template<typename T>
auto arene::base::vector_reference< T >::data ( ) const -> T*
inlineconstexprnoexcept

Obtain a pointer to the stored elements.

Returns
A raw pointer to the elements

◆ empty()

template<typename T>
auto arene::base::vector_reference< T >::empty ( ) const -> bool
inlineconstexprnoexcept

Check if the vector is empty.

Returns
true if the vector is empty, false otherwise

◆ end()

template<typename T>
auto arene::base::vector_reference< T >::end ( ) const -> iterator
inlineconstexprnoexcept

Obtain a const iterator to the end of the vector.

Returns
The iterator

◆ erase() [1/2]

template<typename T>
auto arene::base::vector_reference< T >::erase ( const_iterator first,
const_iterator last ) const -> iterator
inlineconstexprnoexcept

Erase all the element in the specified range.

Parameters
firstAn iterator referring to the start of the range to erase
lastAn iterator referring to the end of the range to erase
Returns
An iterator to the first element following the erased elements, or end() if there is no such element
Precondition
[first,last) Must be a valid iterator range in this

◆ erase() [2/2]

template<typename T>
auto arene::base::vector_reference< T >::erase ( const_iterator iter) const -> iterator
inlineconstexprnoexcept

Erase the element at the specified position.

Parameters
iterAn iterator referring to the element to erase
Returns
An iterator to the first element following the erased element, or end() if there is no such element
Precondition
pos Must be a valid iterator to a live element in this

◆ front()

template<typename T>
auto arene::base::vector_reference< T >::front ( ) const -> T&
inlineconstexprnoexcept

Get a const reference to the first element.

Returns
A reference to the element
Precondition
The vector must not be empty

◆ get_vector_ptr()

template<typename T>
auto arene::base::vector_reference< T >::get_vector_ptr ( vector_reference_detail::ivref_passkey ) const -> inline_vector_detail::vector_base<T>*
inlineconstexprnoexcept

Get a pointer to the underlying vector object.

Returns
A pointer to the underlying vector object

◆ insert() [1/2]

template<typename T>
template<typename InputIterator>
auto arene::base::vector_reference< T >::insert ( const_iterator pos,
InputIterator first,
InputIterator last ) const -> iterator
inlineconstexpr

Insert a range of elements at the specified position.

Parameters
posAn iterator referring to the location to insert the elemnets
firstAn iterator referring to the start of the range to insert
lastAn iterator referring to the end of the range to insert
Returns
An iterator referring to the first inserted value if any, or representing the same position as pos otherwise
Precondition
pos Must be a valid iterator to this

◆ insert() [2/2]

template<typename T>
auto arene::base::vector_reference< T >::insert ( const_iterator pos,
T const & value ) const -> iterator
inlineconstexprnoexcept

Insert a new element at the specified position in the vector by copy-constructing or copy-assigning from the supplied value. Any existing elements from the specified position to the end of the vector are moved to make room.

Parameters
posThe position to insert the new element
valueThe value to copy from
Returns
An iterator referring to the new element
Precondition
size()<Capacity, else ARENE_PRECONDITION violation

◆ max_size()

template<typename T>
auto arene::base::vector_reference< T >::max_size ( ) const -> size_type
inlineconstexprnoexcept

Check if the vector is empty.

Returns
true if the vector is empty, false otherwise

◆ operator[]()

template<typename T>
auto arene::base::vector_reference< T >::operator[] ( size_type index) const -> T&
inlineconstexprnoexcept

Obtain a const reference to the element with the specified index.

Parameters
indexThe index of the element
Returns
A reference to the element
Precondition
index must be less than size()

◆ pop_back()

template<typename T>
void arene::base::vector_reference< T >::pop_back ( ) const
inlineconstexprnoexcept

Destroy the last element in the vector and decrease the size.

Precondition
The vector must not be empty

◆ push_back()

template<typename T>
void arene::base::vector_reference< T >::push_back ( T const & element) const
inlineconstexprnoexcept

Add a new element to the end of the vector as a copy of the supplied value.

Parameters
elementThe value to copy
Precondition
size()<Capacity, else ARENE_PRECONDITION violation

◆ resize()

template<typename T>
void arene::base::vector_reference< T >::resize ( size_type count) const
inlineconstexpr

Resize the vector to the specified size. Default-constructs any missing elements, and destroys any excess.

Parameters
countThe desired size
Precondition
count<=Capacity, else ARENE_PRECONDITION violation

◆ size()

template<typename T>
auto arene::base::vector_reference< T >::size ( ) const -> size_type
inlineconstexprnoexcept

Get the current number of live elements in the vector.

Returns
the size

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