10#include "vecmem/containers/details/reverse_iterator.hpp"
11#include "vecmem/containers/details/static_vector_traits.hpp"
12#include "vecmem/utils/type_traits.hpp"
13#include "vecmem/utils/types.hpp"
29template <
typename TYPE, std::
size_t MAX_SIZE>
37 static_assert(std::is_trivially_copyable<TYPE>::value,
38 "The type of the static vector needs to be trivially "
41 static_assert(std::is_trivially_destructible<TYPE>::value,
42 "The type of the static vector needs to be trivially "
67 using reference = std::add_lvalue_reference_t<value_type>;
70 std::add_lvalue_reference_t<std::add_const_t<value_type> >;
72 using pointer = std::add_pointer_t<value_type>;
74 using const_pointer = std::add_pointer_t<std::add_const_t<value_type> >;
92 VECMEM_HOST_AND_DEVICE
95 VECMEM_HOST_AND_DEVICE
101 std::enable_if_t<details::is_iterator_of<InputIt, value_type>::value,
104 : m_size(0), m_elements() {
127 VECMEM_HOST_AND_DEVICE
130 VECMEM_HOST_AND_DEVICE
134 VECMEM_HOST_AND_DEVICE
137 VECMEM_HOST_AND_DEVICE
141 VECMEM_HOST_AND_DEVICE
144 VECMEM_HOST_AND_DEVICE
148 VECMEM_HOST_AND_DEVICE
151 VECMEM_HOST_AND_DEVICE
155 VECMEM_HOST_AND_DEVICE
158 VECMEM_HOST_AND_DEVICE
167 VECMEM_HOST_AND_DEVICE
183 construct(m_size, *
itr);
189 VECMEM_HOST_AND_DEVICE
192 VECMEM_HOST_AND_DEVICE
197 std::enable_if_t<details::is_iterator_of<InputIt, value_type>::value,
203 auto id = element_id(
pos);
219 template <
typename...
Args>
222 template <
typename...
Args>
226 VECMEM_HOST_AND_DEVICE
230 VECMEM_HOST_AND_DEVICE
233 VECMEM_HOST_AND_DEVICE
236 VECMEM_HOST_AND_DEVICE
240 VECMEM_HOST_AND_DEVICE
243 VECMEM_HOST_AND_DEVICE
246 VECMEM_HOST_AND_DEVICE
255 VECMEM_HOST_AND_DEVICE
259 VECMEM_HOST_AND_DEVICE
263 VECMEM_HOST_AND_DEVICE
267 VECMEM_HOST_AND_DEVICE
270 VECMEM_HOST_AND_DEVICE
273 VECMEM_HOST_AND_DEVICE
277 VECMEM_HOST_AND_DEVICE
280 VECMEM_HOST_AND_DEVICE
283 VECMEM_HOST_AND_DEVICE
287 VECMEM_HOST_AND_DEVICE
291 VECMEM_HOST_AND_DEVICE
295 VECMEM_HOST_AND_DEVICE
304 VECMEM_HOST_AND_DEVICE
307 VECMEM_HOST_AND_DEVICE
310 VECMEM_HOST_AND_DEVICE
313 VECMEM_HOST_AND_DEVICE
316 VECMEM_HOST_AND_DEVICE
323 VECMEM_HOST_AND_DEVICE
332 VECMEM_HOST_AND_DEVICE
345#include "vecmem/containers/impl/static_vector.ipp"
An allocator class that wraps a memory resource.
Definition allocator.hpp:37
Type mimicking std::reverse_iterator.
Definition reverse_iterator.hpp:25
Class mimicking std::vector on top of a fixed sized array.
Definition static_vector.hpp:30
VECMEM_HOST_AND_DEVICE size_type capacity() const
Return the current (fixed) capacity of the vector.
Definition static_vector.ipp:420
VECMEM_HOST_AND_DEVICE void assign(size_type count, const_reference value)
Assign new values to the vector.
Definition static_vector.ipp:124
VECMEM_HOST_AND_DEVICE const_iterator cend() const
Return a constant forward iterator pointing at the end of the vector.
Definition static_vector.ipp:351
std::add_lvalue_reference_t< value_type > reference
Value reference type.
Definition static_vector.hpp:67
std::ptrdiff_t difference_type
Pointer difference type.
Definition static_vector.hpp:55
VECMEM_HOST_AND_DEVICE reference at(size_type pos)
Return a specific element of the vector in a "safe way" (non-const)
Definition static_vector.ipp:31
VECMEM_HOST_AND_DEVICE void resize(std::size_t new_size)
Resize the vector.
Definition static_vector.ipp:288
VECMEM_HOST_AND_DEVICE bool empty() const
Check whether the vector is empty.
Definition static_vector.ipp:400
std::size_t size_type
Size type for the array.
Definition static_vector.hpp:53
std::add_pointer_t< value_type > pointer
Value pointer type.
Definition static_vector.hpp:72
VECMEM_HOST_AND_DEVICE size_type size() const
Return the number of elements in the vector.
Definition static_vector.ipp:406
VECMEM_HOST_AND_DEVICE iterator erase(const_iterator pos)
Remove one element from the vector.
Definition static_vector.ipp:236
VECMEM_HOST_AND_DEVICE static_vector()
Default constructor.
Definition static_vector.ipp:18
typename details::static_vector_type< char, array_max_size *value_size >::type array_type
Type of the array holding the payload of the vector elements.
Definition static_vector.hpp:64
VECMEM_HOST_AND_DEVICE iterator begin()
Return a forward iterator pointing at the beginning of the vector.
Definition static_vector.ipp:318
VECMEM_HOST_AND_DEVICE void clear()
Clear the vector.
Definition static_vector.ipp:282
static constexpr size_type array_max_size
The maximal size of the vector.
Definition static_vector.hpp:58
VECMEM_HOST_AND_DEVICE const_reverse_iterator crend() const
Return a constant reverse iterator pointing at the beginning of the vector.
Definition static_vector.ipp:393
VECMEM_HOST_AND_DEVICE pointer data()
Access the underlying memory array (non-const)
Definition static_vector.ipp:111
VECMEM_HOST_AND_DEVICE reference emplace_back(Args &&... args)
Add a new element at the end of the vector.
VECMEM_HOST_AND_DEVICE static_vector(InputIt other_begin, InputIt other_end)
Construct a vector with values coming from a pair of iterators.
Definition static_vector.hpp:103
VECMEM_HOST_AND_DEVICE void push_back(const_reference value)
Add a new element at the end of the vector.
Definition static_vector.ipp:229
VECMEM_HOST_AND_DEVICE iterator emplace(const_iterator pos, Args &&... args)
Insert a new element into the vector.
VECMEM_HOST_AND_DEVICE iterator end()
Return a forward iterator pointing at the end of the vector.
Definition static_vector.ipp:338
iterator insert(const_iterator pos, InputIt other_begin, InputIt other_end)
Insert a list of elements into the vector.
Definition static_vector.hpp:199
std::add_lvalue_reference_t< std::add_const_t< value_type > > const_reference
Constant value reference type.
Definition static_vector.hpp:70
VECMEM_HOST_AND_DEVICE const_reverse_iterator crbegin() const
Return a constant reverse iterator pointing at the end of the vector.
Definition static_vector.ipp:372
VECMEM_HOST_AND_DEVICE reference back()
Return the last element of the vector (non-const)
Definition static_vector.ipp:90
static_vector(const static_vector &)=default
Copy constructor.
VECMEM_HOST_AND_DEVICE reverse_iterator rend()
Return a reverse iterator pointing at the beginning of the vector.
Definition static_vector.ipp:379
pointer iterator
Forward iterator type.
Definition static_vector.hpp:77
VECMEM_HOST_AND_DEVICE void reserve(size_type new_cap)
Reserve additional storage for the vector.
Definition static_vector.ipp:427
VECMEM_HOST_AND_DEVICE const_iterator cbegin() const
Return a constant forward iterator pointing at the beginning of the vector.
Definition static_vector.ipp:331
const_pointer const_iterator
Constant forward iterator type.
Definition static_vector.hpp:79
VECMEM_HOST_AND_DEVICE iterator insert(const_iterator pos, const_reference value)
Insert a new element into the vector.
Definition static_vector.ipp:143
static constexpr size_type value_size
The size of the vector elements.
Definition static_vector.hpp:60
VECMEM_HOST_AND_DEVICE reverse_iterator rbegin()
Return a reverse iterator pointing at the end of the vector.
Definition static_vector.ipp:358
VECMEM_HOST_AND_DEVICE size_type max_size() const
Return the maximum (fixed) number of elements in the vector.
Definition static_vector.ipp:413
std::add_pointer_t< std::add_const_t< value_type > > const_pointer
Constant value pointer type.
Definition static_vector.hpp:74
TYPE value_type
Type of the array elements.
Definition static_vector.hpp:51
static_vector(static_vector &&) noexcept=default
Move constructor.
VECMEM_HOST_AND_DEVICE reference front()
Return the first element of the vector (non-const)
Definition static_vector.ipp:68
VECMEM_HOST_AND_DEVICE void pop_back()
Remove the last element of the vector.
Definition static_vector.ipp:276
Main namespace for the vecmem classes/functions.
Definition atomic_ref.hpp:16
Helper type for an array in a static_vector with a given type and size.
Definition static_vector_traits.hpp:27