vecmem 1.14.0
Loading...
Searching...
No Matches
Classes | Public Member Functions | List of all members
vecmem::static_vector< TYPE, MAX_SIZE > Class Template Reference

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 destructor, 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.
 
VECMEM_HOST_AND_DEVICE static_vector (const static_vector &parent)
 Copy constructor.
 
VECMEM_HOST_AND_DEVICE ~static_vector ()
 Destructor.
 
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

typedef TYPE value_type
 Type of the array elements.
 
typedef std::size_t size_type
 Size type for the array.
 
typedef std::ptrdiff_t difference_type
 Pointer difference type.
 
typedef details::static_vector_type< char, array_max_size *value_size >::type array_type
 Type of the array holding the payload of the vector elements.
 
typedef value_typereference
 Value reference type.
 
typedef const value_typeconst_reference
 Constant value reference type.
 
typedef value_typepointer
 Value pointer type.
 
typedef const value_typeconst_pointer
 Constant value pointer type.
 
typedef pointer iterator
 Forward iterator type.
 
typedef const_pointer const_iterator
 Constant forward iterator type.
 
typedef vecmem::details::reverse_iterator< iteratorreverse_iterator
 Reverse iterator type.
 
typedef vecmem::details::reverse_iterator< const_iteratorconst_reverse_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.
 

Detailed Description

template<typename TYPE, std::size_t MAX_SIZE>
class vecmem::static_vector< TYPE, MAX_SIZE >

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.

Member Function Documentation

◆ assign()

template<typename TYPE , std::size_t MAX_SIZE>
template<typename InputIt , std::enable_if_t< details::is_iterator_of< InputIt, value_type >::value, bool > = true>
VECMEM_HOST_AND_DEVICE void vecmem::static_vector< TYPE, MAX_SIZE >::assign ( InputIt  other_begin,
InputIt  other_end 
)
inline

Assign new values to the vector.

input iterator eceived by this function.


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