vecmem 1.18.0
|
Class mimicking std::vector
on top of a fixed sized array.
More...
#include <vecmem/containers/static_vector.hpp>
Public Member Functions | |
template<typename... Args> | |
VECMEM_HOST_AND_DEVICE auto | emplace (const_iterator pos, Args &&... args) -> iterator |
template<typename... Args> | |
VECMEM_HOST_AND_DEVICE auto | emplace_back (Args &&... args) -> reference |
Constructors and assignments, mimicking @c std::vector | |
VECMEM_HOST_AND_DEVICE | static_vector () |
Default constructor. | |
VECMEM_HOST_AND_DEVICE | static_vector (size_type size, const_reference value=value_type()) |
Construct a vector with a specific size. | |
template<typename InputIt , std::enable_if_t< details::is_iterator_of< InputIt, value_type >::value, bool > = true> | |
VECMEM_HOST_AND_DEVICE | static_vector (InputIt other_begin, InputIt other_end) |
Construct a vector with values coming from a pair of iterators. | |
static_vector (const static_vector &)=default | |
Copy constructor. | |
static_vector (static_vector &&) noexcept=default | |
Move constructor. | |
~static_vector ()=default | |
Destructor. | |
static_vector & | operator= (const static_vector &)=default |
Copy assignment operator. | |
static_vector & | operator= (static_vector &&) noexcept=default |
Move assignment operator. | |
Vector element access functions | |
VECMEM_HOST_AND_DEVICE reference | at (size_type pos) |
Return a specific element of the vector in a "safe way" (non-const) | |
VECMEM_HOST_AND_DEVICE const_reference | at (size_type pos) const |
Return a specific element of the vector in a "safe way" (const) | |
VECMEM_HOST_AND_DEVICE reference | operator[] (size_type pos) |
Return a specific element of the vector (non-const) | |
VECMEM_HOST_AND_DEVICE const_reference | operator[] (size_type pos) const |
Return a specific element of the vector (const) | |
VECMEM_HOST_AND_DEVICE reference | front () |
Return the first element of the vector (non-const) | |
VECMEM_HOST_AND_DEVICE const_reference | front () const |
Return the first element of the vector (const) | |
VECMEM_HOST_AND_DEVICE reference | back () |
Return the last element of the vector (non-const) | |
VECMEM_HOST_AND_DEVICE const_reference | back () const |
Return the last element of the vector (const) | |
VECMEM_HOST_AND_DEVICE pointer | data () |
Access the underlying memory array (non-const) | |
VECMEM_HOST_AND_DEVICE const_pointer | data () const |
Access the underlying memory array (const) | |
Payload modification functions | |
VECMEM_HOST_AND_DEVICE void | assign (size_type count, const_reference value) |
Assign new values to the vector. | |
template<typename InputIt , std::enable_if_t< details::is_iterator_of< InputIt, value_type >::value, bool > = true> | |
VECMEM_HOST_AND_DEVICE void | assign (InputIt other_begin, InputIt other_end) |
Assign new values to the vector. | |
VECMEM_HOST_AND_DEVICE iterator | insert (const_iterator pos, const_reference value) |
Insert a new element into the vector. | |
VECMEM_HOST_AND_DEVICE iterator | insert (const_iterator pos, size_type count, const_reference value) |
Insert an element N times into the vector. | |
template<typename InputIt , std::enable_if_t< details::is_iterator_of< InputIt, value_type >::value, bool > = true> | |
iterator | insert (const_iterator pos, InputIt other_begin, InputIt other_end) |
Insert a list of elements into the vector. | |
template<typename... Args> | |
VECMEM_HOST_AND_DEVICE iterator | emplace (const_iterator pos, Args &&... args) |
Insert a new element into the vector. | |
template<typename... Args> | |
VECMEM_HOST_AND_DEVICE reference | emplace_back (Args &&... args) |
Add a new element at the end of the vector. | |
VECMEM_HOST_AND_DEVICE void | push_back (const_reference value) |
Add a new element at the end of the vector. | |
VECMEM_HOST_AND_DEVICE iterator | erase (const_iterator pos) |
Remove one element from the vector. | |
VECMEM_HOST_AND_DEVICE iterator | erase (const_iterator first, const_iterator last) |
Remove a list of elements from the vector. | |
VECMEM_HOST_AND_DEVICE void | pop_back () |
Remove the last element of the vector. | |
VECMEM_HOST_AND_DEVICE void | clear () |
Clear the vector. | |
VECMEM_HOST_AND_DEVICE void | resize (std::size_t new_size) |
Resize the vector. | |
VECMEM_HOST_AND_DEVICE void | resize (std::size_t new_size, const_reference value) |
Resize the vector and fill any new elements with the specified value. | |
Iterator providing functions | |
VECMEM_HOST_AND_DEVICE iterator | begin () |
Return a forward iterator pointing at the beginning of the vector. | |
VECMEM_HOST_AND_DEVICE const_iterator | begin () const |
Return a constant forward iterator pointing at the beginning of the vector. | |
VECMEM_HOST_AND_DEVICE const_iterator | cbegin () const |
Return a constant forward iterator pointing at the beginning of the vector. | |
VECMEM_HOST_AND_DEVICE iterator | end () |
Return a forward iterator pointing at the end of the vector. | |
VECMEM_HOST_AND_DEVICE const_iterator | end () const |
Return a constant forward iterator pointing at the end of the vector. | |
VECMEM_HOST_AND_DEVICE const_iterator | cend () const |
Return a constant forward iterator pointing at the end of the vector. | |
VECMEM_HOST_AND_DEVICE reverse_iterator | rbegin () |
Return a reverse iterator pointing at the end of the vector. | |
VECMEM_HOST_AND_DEVICE const_reverse_iterator | rbegin () const |
Return a constant reverse iterator pointing at the end of the vector. | |
VECMEM_HOST_AND_DEVICE const_reverse_iterator | crbegin () const |
Return a constant reverse iterator pointing at the end of the vector. | |
VECMEM_HOST_AND_DEVICE reverse_iterator | rend () |
Return a reverse iterator pointing at the beginning of the vector. | |
VECMEM_HOST_AND_DEVICE const_reverse_iterator | rend () const |
Return a constant reverse iterator pointing at the beginning of the vector. | |
VECMEM_HOST_AND_DEVICE const_reverse_iterator | crend () const |
Return a constant reverse iterator pointing at the beginning of the vector. | |
Capacity checking/modyfying functions | |
VECMEM_HOST_AND_DEVICE bool | empty () const |
Check whether the vector is empty. | |
VECMEM_HOST_AND_DEVICE size_type | size () const |
Return the number of elements in the vector. | |
VECMEM_HOST_AND_DEVICE size_type | max_size () const |
Return the maximum (fixed) number of elements in the vector. | |
VECMEM_HOST_AND_DEVICE size_type | capacity () const |
Return the current (fixed) capacity of the vector. | |
VECMEM_HOST_AND_DEVICE void | reserve (size_type new_cap) |
Reserve additional storage for the vector. | |
Type definitions, mimicking @c std::vector | |
The type of the vector needs to be trivially copyable The type of the vector needs to be trivially destructible | |
using | value_type = TYPE |
Type of the array elements. | |
using | size_type = std::size_t |
Size type for the array. | |
using | difference_type = std::ptrdiff_t |
Pointer difference type. | |
using | array_type = typename details::static_vector_type< char, array_max_size *value_size >::type |
Type of the array holding the payload of the vector elements. | |
using | reference = std::add_lvalue_reference_t< value_type > |
Value reference type. | |
using | const_reference = std::add_lvalue_reference_t< std::add_const_t< value_type > > |
Constant value reference type. | |
using | pointer = std::add_pointer_t< value_type > |
Value pointer type. | |
using | const_pointer = std::add_pointer_t< std::add_const_t< value_type > > |
Constant value pointer type. | |
using | iterator = pointer |
Forward iterator type. | |
using | const_iterator = const_pointer |
Constant forward iterator type. | |
using | reverse_iterator = vecmem::details::reverse_iterator< iterator > |
Reverse iterator type. | |
using | const_reverse_iterator = vecmem::details::reverse_iterator< const_iterator > |
Constant reverse iterator type. | |
static constexpr size_type | array_max_size = MAX_SIZE |
The maximal size of the vector. | |
static constexpr size_type | value_size = sizeof(value_type) |
The size of the vector elements. | |
Class mimicking std::vector
on top of a fixed sized array.
This can come in handy when needing vector arithmetics in device code, without resorting to heap allocations.
The type does come with a significant limitation over std::vector
. It has a maximal/fixed size that needs to be chosen at compile time.
|
inline |
Assign new values to the vector.
input iterator eceived by this function.