vecmem 1.14.0
Loading...
Searching...
No Matches
static_array.hpp
1/*
2 * VecMem project, part of the ACTS project (R&D line)
3 *
4 * (c) 2021 CERN for the benefit of the ACTS project
5 *
6 * Mozilla Public License Version 2.0
7 */
8
9#pragma once
10
11// Local include(s).
12#include "vecmem/containers/details/reverse_iterator.hpp"
13#include "vecmem/containers/details/static_array_traits.hpp"
14#include "vecmem/utils/types.hpp"
15
16// System include(s).
17#include <cstddef>
18#include <type_traits>
19#include <utility>
20
21namespace vecmem {
32template <typename T, std::size_t N>
34
37
39 using value_type = T;
41 using size_type = std::size_t;
43 using difference_type = std::ptrdiff_t;
44
48 using const_reference = const value_type &;
52 using const_pointer = const value_type *;
53
63
65
68
80 VECMEM_HOST
81 constexpr reference at(size_type i);
82
94 VECMEM_HOST
95 constexpr const_reference at(size_type i) const;
96
105 VECMEM_HOST_AND_DEVICE
106 constexpr reference operator[](size_type i);
107
116 VECMEM_HOST_AND_DEVICE
117 constexpr const_reference operator[](size_type i) const;
118
125 template <std::size_t I,
126 std::enable_if_t<I<N, bool> = true>
127 VECMEM_HOST_AND_DEVICE constexpr reference get() noexcept;
128
135 template <std::size_t I,
136 std::enable_if_t<I<N, bool> = true>
137 VECMEM_HOST_AND_DEVICE constexpr const_reference get()
139
145 VECMEM_HOST_AND_DEVICE
146 constexpr reference front(void);
147
153 VECMEM_HOST_AND_DEVICE
154 constexpr const_reference front(void) const;
155
161 VECMEM_HOST_AND_DEVICE
162 constexpr reference back(void);
163
169 VECMEM_HOST_AND_DEVICE
171
177 VECMEM_HOST_AND_DEVICE
178 constexpr pointer data(void);
179
185 VECMEM_HOST_AND_DEVICE
186 constexpr const_pointer data(void) const;
187
189
192
194 VECMEM_HOST_AND_DEVICE
195 constexpr iterator begin();
198 VECMEM_HOST_AND_DEVICE
202 VECMEM_HOST_AND_DEVICE
204
206 VECMEM_HOST_AND_DEVICE
207 constexpr iterator end();
209 VECMEM_HOST_AND_DEVICE
212 VECMEM_HOST_AND_DEVICE
214
216 VECMEM_HOST_AND_DEVICE
219 VECMEM_HOST_AND_DEVICE
222 VECMEM_HOST_AND_DEVICE
224
226 VECMEM_HOST_AND_DEVICE
230 VECMEM_HOST_AND_DEVICE
234 VECMEM_HOST_AND_DEVICE
236
238
241
243 VECMEM_HOST_AND_DEVICE
244 constexpr bool empty() const;
246 VECMEM_HOST_AND_DEVICE
249 VECMEM_HOST_AND_DEVICE
250 constexpr size_type max_size() const;
251
253
256
258 VECMEM_HOST_AND_DEVICE
259 void fill(const_reference value);
260
262
264 typename details::static_array_type<T, N>::type m_array;
265
266}; // struct static_array
267
269template <typename T, std::size_t N>
270VECMEM_HOST_AND_DEVICE bool operator==(const static_array<T, N> &lhs,
273template <typename T, std::size_t N>
274VECMEM_HOST_AND_DEVICE bool operator!=(const static_array<T, N> &lhs,
276
278template <std::size_t I, class T, std::size_t N,
279 std::enable_if_t<I<N, bool> = true> VECMEM_HOST_AND_DEVICE constexpr T
282template <std::size_t I, class T, std::size_t N,
283 std::enable_if_t<I<N, bool> = true>
284 VECMEM_HOST_AND_DEVICE constexpr const T &get(
286
287} // namespace vecmem
288
289// Include the implementation.
290#include "impl/static_array.ipp"
Type mimicking std::reverse_iterator.
Definition reverse_iterator.hpp:25
Main namespace for the vecmem classes/functions.
Definition atomic_ref.hpp:16
VECMEM_HOST_AND_DEVICE constexpr const auto & get(const tuple< Ts... > &t) noexcept
Get a constant element out of a tuple.
Definition tuple.ipp:58
std::vector< T, vecmem::polymorphic_allocator< T > > vector
Alias type for vectors with our polymorphic allocator.
Definition vector.hpp:35
Simple statically-sized array-like class designed for use in device code.
Definition static_array.hpp:33
const_pointer const_iterator
Constant forward iterator type.
Definition static_array.hpp:57
value_type * pointer
Value pointer type.
Definition static_array.hpp:50
value_type & reference
Value reference type.
Definition static_array.hpp:46
const value_type & const_reference
Constant value reference type.
Definition static_array.hpp:48
const value_type * const_pointer
Constant value pointer type.
Definition static_array.hpp:52
std::ptrdiff_t difference_type
Pointer difference type.
Definition static_array.hpp:43
T value_type
Type of the array elements.
Definition static_array.hpp:39
VECMEM_HOST_AND_DEVICE constexpr reference operator[](size_type i)
Accessor method.
Definition static_array.ipp:50
std::size_t size_type
Size type for the array.
Definition static_array.hpp:41
pointer iterator
Forward iterator type.
Definition static_array.hpp:55
VECMEM_HOST constexpr reference at(size_type i)
Bounds-checked accessor method.
Definition static_array.ipp:22