vecmem 1.18.0
Loading...
Searching...
No Matches
schema_traits.hpp
1/* VecMem project, part of the ACTS project (R&D line)
2 *
3 * (c) 2023-2025 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/edm/schema.hpp"
11#include "vecmem/utils/type_traits.hpp"
12
13// System include(s).
14#include <type_traits>
15
16namespace vecmem {
17namespace edm {
18namespace type {
19namespace details {
20
23
24template <typename T>
25struct add_const;
26
27template <typename TYPE>
28struct add_const<type::scalar<TYPE>> {
30}; // struct add_const
31
32template <typename TYPE>
33struct add_const<type::vector<TYPE>> {
35}; // struct add_const
36
37template <typename TYPE>
40}; // struct add_const
41
42template <typename T>
43using add_const_t = typename add_const<T>::type;
44
46
49
50template <typename T>
51struct remove_cv;
52
53template <typename TYPE>
54struct remove_cv<type::scalar<TYPE>> {
56}; // struct remove_cv
57
58template <typename TYPE>
59struct remove_cv<type::vector<TYPE>> {
61}; // struct remove_cv
62
63template <typename TYPE>
66}; // struct remove_cv
67
68template <typename T>
69using remove_cv_t = typename remove_cv<T>::type;
70
72
75
76template <typename T>
77struct is_scalar {
78 static constexpr bool value = false;
79}; // struct is_scalar
80
81template <typename TYPE>
82struct is_scalar<type::scalar<TYPE>> {
83 static constexpr bool value = true;
84}; // struct is_scalar
85
86template <typename T>
87constexpr bool is_scalar_v = is_scalar<T>::value;
88
89template <typename T>
90struct is_vector {
91 static constexpr bool value = false;
92}; // struct is_vector
93
94template <typename TYPE>
95struct is_vector<type::vector<TYPE>> {
96 static constexpr bool value = true;
97}; // struct is_vector
98
99template <typename TYPE>
100struct is_vector<type::jagged_vector<TYPE>> {
101 static constexpr bool value = true;
102}; // struct is_vector
103
104template <typename T>
105constexpr bool is_vector_v = is_vector<T>::value;
106
107template <typename T>
109 static constexpr bool value = false;
110}; // struct is_jagged_vector
111
112template <typename TYPE>
113struct is_jagged_vector<type::jagged_vector<TYPE>> {
114 static constexpr bool value = true;
115}; // struct is_jagged_vector
116
117template <typename T>
118constexpr bool is_jagged_vector_v = is_jagged_vector<T>::value;
119
121
124
125template <typename TYPE1, typename TYPE2>
127 static constexpr bool value = false;
128}; // struct is_same_nc
129
130template <typename TYPE1, typename TYPE2>
131struct is_same_nc<type::scalar<TYPE1>, type::scalar<TYPE2>> {
132 static constexpr bool value =
134}; // struct is_same_nc
135
136template <typename TYPE1, typename TYPE2>
137struct is_same_nc<type::vector<TYPE1>, type::vector<TYPE2>> {
138 static constexpr bool value =
140}; // struct is_same_nc
141
142template <typename TYPE1, typename TYPE2>
143struct is_same_nc<type::jagged_vector<TYPE1>, type::jagged_vector<TYPE2>> {
144 static constexpr bool value =
146}; // struct is_same_nc
147
148template <typename TYPE1, typename TYPE2>
149constexpr bool is_same_nc_v = is_same_nc<TYPE1, TYPE2>::value;
150
152
153} // namespace details
154} // namespace type
155
156namespace details {
157
160
162template <typename T>
164
169template <typename... VARTYPES>
173
175template <typename... VARTYPES>
176using add_const_t = typename add_const<VARTYPES...>::type;
177
179template <typename T>
181
186template <typename... VARTYPES>
190
192template <typename... VARTYPES>
193using remove_cv_t = typename remove_cv<VARTYPES...>::type;
194
196
199
201template <typename T>
203
208template <typename... VARTYPES>
210 static constexpr bool value =
211 vecmem::details::disjunction_v<type::details::is_scalar<VARTYPES>...>;
212}; // struct has_scalar
213
215template <typename... VARTYPES>
216constexpr bool has_scalar_v = has_scalar<schema<VARTYPES...>>::value;
217
219template <typename T>
221
226template <typename... VARTYPES>
228 static constexpr bool value =
229 vecmem::details::disjunction_v<type::details::is_vector<VARTYPES>...>;
230}; // struct has_vector
231
233template <typename... VARTYPES>
234constexpr bool has_vector_v = has_vector<schema<VARTYPES...>>::value;
235
237template <typename T>
239
244template <typename... VARTYPES>
246 static constexpr bool value = vecmem::details::disjunction_v<
248}; // struct has_jagged_vector
249
251template <typename... VARTYPES>
252constexpr bool has_jagged_vector_v =
254
256
257} // namespace details
258} // namespace edm
259} // namespace vecmem
An allocator class that wraps a memory resource.
Definition allocator.hpp:37
Main namespace for the vecmem classes/functions.
Definition atomic_ref.hpp:16
Helper trait for detecting when a type is a non-const version of another.
Definition type_traits.hpp:37
Technical base type for add_const<schema<VARTYPES...>>
Definition schema_traits.hpp:163
Technical base type for has_jagged_vector<schema<VARTYPES...>>
Definition schema_traits.hpp:238
Technical base type for has_scalar<schema<VARTYPES...>>
Definition schema_traits.hpp:202
Technical base type for has_vector<schema<VARTYPES...>>
Definition schema_traits.hpp:220
Technical base type for remove_cv<schema<VARTYPES...>>
Definition schema_traits.hpp:180
Meta type describing the "schema" of an SoA container.
Definition schema.hpp:46
Definition schema_traits.hpp:25
Definition schema_traits.hpp:108
Definition schema_traits.hpp:126
Definition schema_traits.hpp:77
Definition schema_traits.hpp:90
Definition schema_traits.hpp:51
2D jagged vector variable
Definition schema.hpp:33
Scalar variable, one for a whole container.
Definition schema.hpp:19
1D vector variable
Definition schema.hpp:26