vecmem 1.14.0
Loading...
Searching...
No Matches
device_array.hpp
1/* VecMem project, part of the ACTS project (R&D line)
2 *
3 * (c) 2021 CERN for the benefit of the ACTS project
4 *
5 * Mozilla Public License Version 2.0
6 */
7#pragma once
8
9// Local include(s).
10#include "vecmem/containers/data/vector_view.hpp"
11#include "vecmem/containers/details/reverse_iterator.hpp"
12#include "vecmem/utils/type_traits.hpp"
13#include "vecmem/utils/types.hpp"
14
15// System include(s).
16#include <cstddef>
17#include <type_traits>
18
19namespace vecmem {
20
27template <typename T, std::size_t N>
29
30public:
33
35 typedef T value_type;
37 typedef std::size_t size_type;
39 typedef std::ptrdiff_t difference_type;
40
48 typedef const value_type* const_pointer;
49
59
61
63 VECMEM_HOST_AND_DEVICE
66 template <
67 typename OTHERTYPE,
68 std::enable_if_t<details::is_same_nc<T, OTHERTYPE>::value, bool> = true>
69 VECMEM_HOST_AND_DEVICE explicit device_array(
72 VECMEM_HOST_AND_DEVICE
73 device_array(const device_array& parent);
74
76 VECMEM_HOST_AND_DEVICE
78
81
83 VECMEM_HOST_AND_DEVICE
86 VECMEM_HOST_AND_DEVICE
88
90 VECMEM_HOST_AND_DEVICE
93 VECMEM_HOST_AND_DEVICE
95
97 VECMEM_HOST_AND_DEVICE
100 VECMEM_HOST_AND_DEVICE
101 const_reference front() const;
102
104 VECMEM_HOST_AND_DEVICE
105 reference back();
107 VECMEM_HOST_AND_DEVICE
108 const_reference back() const;
109
111 VECMEM_HOST_AND_DEVICE
112 pointer data();
114 VECMEM_HOST_AND_DEVICE
115 const_pointer data() const;
116
118
121
123 VECMEM_HOST_AND_DEVICE
124 iterator begin();
127 VECMEM_HOST_AND_DEVICE
128 const_iterator begin() const;
131 VECMEM_HOST_AND_DEVICE
132 const_iterator cbegin() const;
133
135 VECMEM_HOST_AND_DEVICE
136 iterator end();
138 VECMEM_HOST_AND_DEVICE
139 const_iterator end() const;
141 VECMEM_HOST_AND_DEVICE
142 const_iterator cend() const;
143
145 VECMEM_HOST_AND_DEVICE
148 VECMEM_HOST_AND_DEVICE
151 VECMEM_HOST_AND_DEVICE
153
155 VECMEM_HOST_AND_DEVICE
159 VECMEM_HOST_AND_DEVICE
163 VECMEM_HOST_AND_DEVICE
165
167
170
172 VECMEM_HOST_AND_DEVICE
173 constexpr bool empty() const;
175 VECMEM_HOST_AND_DEVICE
176 constexpr size_type size() const;
178 VECMEM_HOST_AND_DEVICE
179 constexpr size_type max_size() const;
180
182
183private:
185 pointer m_ptr;
186
187}; // class device_array
188
189} // namespace vecmem
190
191// Include the implementation.
192#include "vecmem/containers/impl/device_array.ipp"
Class holding data about a 1 dimensional vector/array.
Definition vector_view.hpp:38
Type mimicking std::reverse_iterator.
Definition reverse_iterator.hpp:25
Class mimicking a host-filled std::array in "device code".
Definition device_array.hpp:28
VECMEM_HOST_AND_DEVICE iterator end()
Return a forward iterator pointing at the end of the array.
Definition device_array.ipp:170
VECMEM_HOST_AND_DEVICE reference at(size_type pos)
Return a specific element of the array in a "safe way" (non-const)
Definition device_array.ipp:59
VECMEM_HOST_AND_DEVICE pointer data()
Access the underlying memory array (non-const)
Definition device_array.ipp:138
VECMEM_HOST_AND_DEVICE const_reverse_iterator crend() const
Return a constant reverse iterator pointing at the beginning of the array.
Definition device_array.ipp:221
VECMEM_HOST_AND_DEVICE reference front()
Return the first element of the array (non-const)
Definition device_array.ipp:96
VECMEM_HOST_AND_DEVICE reference operator[](size_type pos)
Return a specific element of the array (non-const)
Definition device_array.ipp:80
T value_type
Type of the array elements.
Definition device_array.hpp:35
VECMEM_HOST_AND_DEVICE constexpr bool empty() const
Check whether the array is empty.
Definition device_array.ipp:228
value_type * pointer
Value pointer type.
Definition device_array.hpp:46
const value_type * const_pointer
Constant value pointer type.
Definition device_array.hpp:48
value_type & reference
Value reference type.
Definition device_array.hpp:42
std::size_t size_type
Size type for the array.
Definition device_array.hpp:37
VECMEM_HOST_AND_DEVICE const_reverse_iterator crbegin() const
Return a constant reverse iterator pointing at the end of the array.
Definition device_array.ipp:201
VECMEM_HOST_AND_DEVICE const_iterator cbegin() const
Return a constant forward iterator pointing at the beginning of the array.
Definition device_array.ipp:163
const_pointer const_iterator
Constant forward iterator type.
Definition device_array.hpp:53
VECMEM_HOST_AND_DEVICE reverse_iterator rbegin()
Return a reverse iterator pointing at the end of the array.
Definition device_array.ipp:188
VECMEM_HOST_AND_DEVICE const_iterator cend() const
Return a constant forward iterator pointing at the end of the array.
Definition device_array.ipp:182
VECMEM_HOST_AND_DEVICE device_array & operator=(const device_array &rhs)
Copy assignment operator.
Definition device_array.ipp:43
VECMEM_HOST_AND_DEVICE constexpr size_type max_size() const
Return the maximum (fixed) number of elements in the array.
Definition device_array.ipp:241
VECMEM_HOST_AND_DEVICE constexpr size_type size() const
Return the number of elements in the array.
Definition device_array.ipp:234
std::ptrdiff_t difference_type
Pointer difference type.
Definition device_array.hpp:39
const value_type & const_reference
Constant value reference type.
Definition device_array.hpp:44
VECMEM_HOST_AND_DEVICE reverse_iterator rend()
Return a reverse iterator pointing at the beginning of the array.
Definition device_array.ipp:208
VECMEM_HOST_AND_DEVICE reference back()
Return the last element of the array (non-const)
Definition device_array.ipp:117
vecmem::details::reverse_iterator< const_iterator > const_reverse_iterator
Constant reverse iterator type.
Definition device_array.hpp:58
pointer iterator
Forward iterator type.
Definition device_array.hpp:51
vecmem::details::reverse_iterator< iterator > reverse_iterator
Reverse iterator type.
Definition device_array.hpp:55
VECMEM_HOST_AND_DEVICE iterator begin()
Return a forward iterator pointing at the beginning of the array.
Definition device_array.ipp:150
Main namespace for the vecmem classes/functions.
Definition atomic_ref.hpp:16
std::vector< T, vecmem::polymorphic_allocator< T > > vector
Alias type for vectors with our polymorphic allocator.
Definition vector.hpp:35