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

a container similar to std::vector<T> that uses an external buffer for storage More...

Inheritance diagram for arene::base::external_vector< T >:
Inheritance graph

Public Member Functions

 external_vector () noexcept
 construct an empty external_vector
 
 external_vector (external_vector &&other) noexcept
 construct an external_vector from another external_vector
 
 external_vector (external_vector const &)=delete
 deleted copy constructor
 
 external_vector (span< byte > buffer) noexcept
 construct an empty external_vector
 
template<class U = value_type, constraints< std::enable_if_t< std::is_move_constructible< U >::value > > = nullptr>
 external_vector (span< byte > buffer, external_vector &&other) noexcept(std::is_nothrow_move_constructible< value_type >::value)
 construct an external_vector from another external_vector
 
template<class U = value_type, constraints< std::enable_if_t< std::is_copy_constructible< U >::value > > = nullptr>
 external_vector (span< byte > buffer, external_vector const &other) noexcept(std::is_nothrow_copy_constructible< value_type >::value)
 construct an external_vector from another external_vector
 
template<class I, constraints< std::enable_if_t< is_input_iterator_v< I > >, std::enable_if_t< std::is_constructible< value_type, typename std::iterator_traits< I >::reference >::value > > = nullptr>
 external_vector (span< byte > buffer, I first, I last) noexcept(denotes_nothrow_iterable_range_v< I > &&std::is_nothrow_constructible< value_type, typename std::iterator_traits< I >::reference >::value)
 construct an external_vector from a range
 
template<class U = value_type, constraints< std::enable_if_t< std::is_default_constructible< U >::value > > = nullptr>
 external_vector (span< byte > buffer, size_type count) noexcept(std::is_nothrow_default_constructible< value_type >::value)
 construct an external_vector with default constructed values
 
template<class U = value_type, constraints< std::enable_if_t< std::is_copy_constructible< U >::value > > = nullptr>
 external_vector (span< byte > buffer, size_type count, value_type const &value) noexcept(std::is_nothrow_copy_constructible< value_type >::value)
 construct an external_vector with copies of a value
 
template<class U = value_type, constraints< std::enable_if_t< std::is_copy_constructible< U >::value > > = nullptr>
 external_vector (span< byte > buffer, std::initializer_list< value_type > init_list) noexcept(std::is_nothrow_copy_constructible< value_type >::value)
 construct an external_vector from a list of values
 
 ~external_vector ()=default
 default destructor
 
auto operator= (enable_if_assignable_t< false, value_type && >) -> external_vector &=delete
 deleted move assignment operator
 
auto operator= (enable_if_assignable_t< false, value_type const & >) -> external_vector &=delete
 deleted copy assignment operator
 
auto operator= (enable_if_assignable_t< true, value_type && > other) noexcept(std::is_nothrow_move_constructible< value_type >::value &&std::is_nothrow_move_assignable< value_type >::value) -> external_vector &
 move assignment operator
 
auto operator= (enable_if_assignable_t< true, value_type const & > other) noexcept(std::is_nothrow_copy_constructible< value_type >::value &&std::is_nothrow_copy_assignable< value_type >::value) -> external_vector &
 copy assignment operator
 
template<class U = value_type, constraints< std::enable_if_t< std::is_copy_constructible< U >::value &&std::is_copy_assignable< U >::value > > = nullptr>
auto operator= (std::initializer_list< value_type > init_list) noexcept(std::is_nothrow_copy_constructible< value_type >::value &&std::is_nothrow_copy_assignable< value_type >::value) -> external_vector &
 assignment from a list of values
 
auto swap (external_vector &other) noexcept -> void
 swap contents with a different external_vector
 

Static Public Member Functions

static auto get_storage (typename external_vector_detail::external_storage_base< T >::storage_access_tag, external_vector_detail::external_storage_base< T > *const self) noexcept -> storage_base &
 Internal function to get access to the storage for an external_vector.
 
static auto get_storage (typename external_vector_detail::external_storage_base< T >::storage_access_tag, external_vector_detail::external_storage_base< T > const *const self) noexcept -> storage_base const &
 Internal function to get access to the storage for an external_vector.
 

Friends

auto swap (external_vector &lhs, external_vector &rhs) noexcept -> void
 swaps all the elements between two external_vector values
 

Detailed Description

template<class T>
class arene::base::external_vector< T >

a container similar to std::vector<T> that uses an external buffer for storage

Template Parameters
Tvalue type of the container

A container where storage for the values is provided as a buffer, which is external to the class. The lifetime of the external buffer must bound the lifetime of external_vector (i.e. the external buffer must outlive the external_vector that uses it).

Constructor & Destructor Documentation

◆ ~external_vector()

template<class T>
arene::base::external_vector< T >::~external_vector ( )
default

default destructor

Detroys values stored in the external buffer.

◆ external_vector() [1/10]

template<class T>
arene::base::external_vector< T >::external_vector ( span< byte > buffer)
inlineexplicitnoexcept

construct an empty external_vector

Parameters
bufferexternal buffer of bytes
Precondition
the alignment of buffer matches the alignment of value_type
the size of buffer is an exact multiple of sizeof(value_type)
Postcondition
size() == 0
capacity() == buffer.size() / sizeof(value_type)

Constructs an empty external_vector that is configured to use buffer as external storage.

◆ external_vector() [2/10]

template<class T>
arene::base::external_vector< T >::external_vector ( )
inlinenoexcept

construct an empty external_vector

Postcondition
size() == 0
capacity() == 0

Constructs an empty external_vector without initializing any external storage.

◆ external_vector() [3/10]

template<class T>
template<class I, constraints< std::enable_if_t< is_input_iterator_v< I > >, std::enable_if_t< std::is_constructible< value_type, typename std::iterator_traits< I >::reference >::value > > = nullptr>
arene::base::external_vector< T >::external_vector ( span< byte > buffer,
I first,
I last )
inlinenoexcept

construct an external_vector from a range

Template Parameters
Iinput iterator type
Parameters
bufferexternal buffer of bytes
firstbeginning of the range of values
lastend of the range of values
Precondition
the alignment of buffer matches the alignment of value_type
the size of buffer is an exact multiple of sizeof(value_type)
std::distance(first, last) does not exceed the number of values that can be stored in buffer

Constructs an external_vector from range [first, last) .

◆ external_vector() [4/10]

template<class T>
template<class U = value_type, constraints< std::enable_if_t< std::is_default_constructible< U >::value > > = nullptr>
arene::base::external_vector< T >::external_vector ( span< byte > buffer,
size_type count )
inlinenoexcept

construct an external_vector with default constructed values

Template Parameters
Udummy used to constrain this constructor to value types that are default constructible
Parameters
bufferexternal buffer of bytes
countsize of the external_vector
Precondition
the alignment of buffer matches the alignment of value_type
the size of buffer is an exact multiple of sizeof(value_type)
count does not exceed the number of values that can be stored in buffer

Constructs an external_vector containing count number of default constructed values.

◆ external_vector() [5/10]

template<class T>
template<class U = value_type, constraints< std::enable_if_t< std::is_copy_constructible< U >::value > > = nullptr>
arene::base::external_vector< T >::external_vector ( span< byte > buffer,
size_type count,
value_type const & value )
inlinenoexcept

construct an external_vector with copies of a value

Template Parameters
Udummy used to constrain this constructor to value types that are copy constructible
Parameters
bufferexternal buffer of bytes
countsize of the external_vector
valuevalue to copy into the external_vector
Precondition
the alignment of buffer matches the alignment of value_type
the size of buffer is an exact multiple of sizeof(value_type)
count does not exceed the number of values that can be stored in buffer

Constructs an external_vector containing count number of copies of value.

◆ external_vector() [6/10]

template<class T>
template<class U = value_type, constraints< std::enable_if_t< std::is_move_constructible< U >::value > > = nullptr>
arene::base::external_vector< T >::external_vector ( span< byte > buffer,
external_vector< T > && other )
inlinenoexcept

construct an external_vector from another external_vector

Template Parameters
Udummy used to constrain this constructor to value types that are move constructible
Parameters
bufferexternal buffer of bytes
otheranother external_vector
Precondition
the alignment of buffer matches the alignment of value_type
the size of buffer is an exact multiple of sizeof(value_type)
other.size() does not exceed the number of values that can be stored in buffer
buffer does not alias with the buffer managed by other

Constructs an external_vector from other, moving values from the external buffer managed by other to buffer.

Postcondition
other is in a valid but unspecified state

◆ external_vector() [7/10]

template<class T>
template<class U = value_type, constraints< std::enable_if_t< std::is_copy_constructible< U >::value > > = nullptr>
arene::base::external_vector< T >::external_vector ( span< byte > buffer,
external_vector< T > const & other )
inlinenoexcept

construct an external_vector from another external_vector

Template Parameters
Udummy used to constrain this constructor to value types that are copy constructible
Parameters
bufferexternal buffer of bytes
otheranother external_vector
Precondition
the alignment of buffer matches the alignment of value_type
the size of buffer is an exact multiple of sizeof(value_type)
other.size() does not exceed the number of values that can be stored in buffer
buffer does not alias with the buffer managed by other

Constructs an external_vector from other, copying values from the external buffer managed by other to buffer.

Postcondition
std::equal(this->begin(), this->end(), other.begin(), other.end()) is true

◆ external_vector() [8/10]

template<class T>
template<class U = value_type, constraints< std::enable_if_t< std::is_copy_constructible< U >::value > > = nullptr>
arene::base::external_vector< T >::external_vector ( span< byte > buffer,
std::initializer_list< value_type > init_list )
inlinenoexcept

construct an external_vector from a list of values

Template Parameters
Udummy used to constrain this constructor to value types that are copy constructible
Parameters
bufferexternal buffer of bytes
init_listvalues to copy
Precondition
the alignment of buffer matches the alignment of value_type
the size of buffer is an exact multiple of sizeof(value_type)
init_list.size() does not exceed the number of values that can be stored in buffer

Constructs an external_vector with copies of values in init_list.

◆ external_vector() [9/10]

template<class T>
arene::base::external_vector< T >::external_vector ( external_vector< T > && other)
inlinenoexcept

construct an external_vector from another external_vector

Parameters
otherexternal_vector to move from

Constructs an external_vector by moving contents from other. This does not invoke any constructors of value_type.

Postcondition
other is in a valid but unspecified state

◆ external_vector() [10/10]

template<class T>
arene::base::external_vector< T >::external_vector ( external_vector< T > const & )
delete

deleted copy constructor

Member Function Documentation

◆ get_storage() [1/2]

template<class T>
static auto arene::base::external_vector< T >::get_storage ( typename external_vector_detail::external_storage_base< T >::storage_access_tag ,
external_vector_detail::external_storage_base< T > *const self ) -> storage_base&
inlinestaticnoexcept

Internal function to get access to the storage for an external_vector.

Parameters
selfThe pointer to the internal base class
Returns
A reference to the storage class

◆ get_storage() [2/2]

template<class T>
static auto arene::base::external_vector< T >::get_storage ( typename external_vector_detail::external_storage_base< T >::storage_access_tag ,
external_vector_detail::external_storage_base< T > const *const self ) -> storage_base const&
inlinestaticnoexcept

Internal function to get access to the storage for an external_vector.

Parameters
selfThe pointer to the internal base class
Returns
A reference to the storage class

◆ operator=() [1/5]

template<class T>
auto arene::base::external_vector< T >::operator= ( enable_if_assignable_t< false, value_type && > ) -> external_vector &=delete
delete

deleted move assignment operator

Note
The argument type resolves to external_vector&& if std::is_move_constructible<value_type>::value && std::is_move_assignable<value_type>::value is false
The move assignment operator is deleted if std::is_move_constructible<value_type>::value && std::is_move_assignable<value_type>::value is false

◆ operator=() [2/5]

template<class T>
auto arene::base::external_vector< T >::operator= ( enable_if_assignable_t< false, value_type const & > ) -> external_vector &=delete
delete

deleted copy assignment operator

Note
The argument type resolves to external_vector const& if std::is_copy_constructible<value_type>::value && std::is_copy_assignable<value_type>::value is false
The copy assignment operator is deleted if std::is_copy_constructible<value_type>::value && std::is_copy_assignable<value_type>::value is false

◆ operator=() [3/5]

template<class T>
auto arene::base::external_vector< T >::operator= ( enable_if_assignable_t< true, value_type && > other) -> external_vector&
inlinenoexcept

move assignment operator

Parameters
otherexternal_vector to move values from
Returns
*this

Replaces the contents of the container with values from other. The first std::min(size(), other.size()) values are move assigned; remaining values are move constructed.

Precondition
capacity() <= other.size()
Postcondition
other is in a valid but unspecified state
Note
The argument type resolves to external_vector&& if std::is_move_constructible<value_type>::value && std::is_move_assignable<value_type>::value is true
This assignment operator is deleted if std::is_move_constructible<value_type>::value && std::is_move_assignable<value_type>::value is false

◆ operator=() [4/5]

template<class T>
auto arene::base::external_vector< T >::operator= ( enable_if_assignable_t< true, value_type const & > other) -> external_vector&
inlinenoexcept

copy assignment operator

Parameters
otherexternal_vector to copy values from
Returns
*this

Replaces the contents of the container with values from other. The first std::min(size(), other.size()) values are copy assigned; remaining values are copy constructed.

Precondition
capacity() <= other.size()
Postcondition
std::equal(this->begin(), this->end(), other.begin(), other.end()) is true
Note
The argument type resolves to external_vector const& if std::is_copy_constructible<value_type>::value && std::is_copy_assignable<value_type>::value is true
This assignment operator is deleted if std::is_copy_constructible<value_type>::value && std::is_copy_assignable<value_type>::value is false

◆ operator=() [5/5]

template<class T>
template<class U = value_type, constraints< std::enable_if_t< std::is_copy_constructible< U >::value &&std::is_copy_assignable< U >::value > > = nullptr>
auto arene::base::external_vector< T >::operator= ( std::initializer_list< value_type > init_list) -> external_vector&
inlinenoexcept

assignment from a list of values

Template Parameters
Udummy used to constrain this assignment operator to value types that are copy constructible and copy assignable
Parameters
init_listvalues to copy
Returns
*this

Replaces the contents of the container with values from other. The first std::min(size(), other.size()) values are copy assigned; remaining values are copy constructed.

Precondition
capacity() <= other.size()
Postcondition
std::equal(this->begin(), this->end(), other.begin(), other.end()) is true

◆ swap()

template<class T>
auto arene::base::external_vector< T >::swap ( external_vector< T > & other) -> void
inlinenoexcept

swap contents with a different external_vector

Parameters
otherexternal_vector to swap contents with
Note
does not swap individual elements but rather the underlying buffer associated with each external_vector

Friends And Related Symbol Documentation

◆ swap

template<class T>
auto swap ( external_vector< T > & lhs,
external_vector< T > & rhs ) -> void
friend

swaps all the elements between two external_vector values

Parameters
lhsthe left hand vector to swap
rhsthe right hand vector to swap
Postcondition
equivalent to having called lhs.swap(rhs);
See also
external_vector::swap.

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