kokkos-utils
0.0.5
Toggle main menu visibility
Loading...
Searching...
No Matches
type_list.hpp
Go to the documentation of this file.
1
#ifndef KOKKOS_UTILS_IMPL_TYPE_LIST_HPP
2
#define KOKKOS_UTILS_IMPL_TYPE_LIST_HPP
3
4
#include "impl/Kokkos_Utilities.hpp"
5
11
12
namespace
Kokkos::utils::impl
13
{
16
template
<
typename
T>
17
struct
is_type_list
:
public
std::false_type {};
18
19
template
<
typename
... T>
20
struct
is_type_list
<
Kokkos
::Impl::type_list<T...>> :
public
std::true_type {};
21
22
template
<
typename
T>
23
inline
constexpr
bool
is_type_list_v
=
is_type_list<T>::value
;
25
28
template
<
typename
...>
29
struct
make_type_list
;
30
31
template
<
typename
T>
requires
Kokkos::utils::impl::is_type_list_v<T>
32
struct
make_type_list<T>
33
{
34
using
type
= T;
35
};
36
37
template
<
typename
T,
typename
... Ts>
38
struct
make_type_list
<T, Ts...>
39
{
40
using
type
= Kokkos::Impl::type_list<T, Ts...>;
41
};
42
43
template
<
typename
... Args>
44
using
make_type_list_t
=
typename
make_type_list
<Args...>::type;
46
49
template
<
typename
>
50
struct
TypeListSize
;
51
52
template
<
typename
... Ts>
53
struct
TypeListSize
<
Kokkos
::Impl::type_list<Ts...>> : std::integral_constant<size_t, sizeof...(Ts)> {};
54
55
template
<
typename
T>
56
inline
constexpr
size_t
type_list_size_v
=
TypeListSize<T>::value
;
58
61
template
<
typename
,
typename
...>
62
struct
TypeListContains
;
63
65
template
<
typename
U,
typename
T,
typename
... Ts>
66
struct
TypeListContains
<U, T, Ts...> :
public
std::disjunction<std::is_same<U, T>, std::is_same<U, Ts>...> {};
67
69
template
<
typename
U,
typename
... Ts>
70
struct
TypeListContains
<U,
Kokkos
::Impl::type_list<Ts...>> : std::disjunction<std::is_same<U, Ts>...> {};
71
72
template
<
typename
U,
typename
... TypeList>
73
inline
constexpr
bool
type_list_contains_v
=
TypeListContains
<U, TypeList...>::value;
75
78
template
<
size_t
,
typename
>
79
struct
TypeListAt
;
80
81
template
<
size_t
I,
typename
Head,
typename
... Tail>
82
struct
TypeListAt
<I,
Kokkos
::Impl::type_list<Head, Tail...>>
83
:
TypeListAt
<I - 1, Kokkos::Impl::type_list<Tail...>> {};
84
85
template
<
class
Head,
class
... Tail>
86
struct
TypeListAt
<0,
Kokkos
::Impl::type_list<Head, Tail...>>
87
{
88
using
type
= Head;
89
};
90
91
template
<
size_t
I,
typename
T>
92
using
type_list_at_t
=
typename
TypeListAt<I, T>::type
;
94
97
template
<
template
<
typename
>
typename
,
typename
>
98
struct
TransformTypeList
;
99
100
template
<
template
<
typename
>
typename
TransformerType,
typename
... Ts>
101
struct
TransformTypeList
<TransformerType,
Kokkos
::Impl::type_list<Ts...>>
102
{
103
using
type
= Kokkos::Impl::concat_type_list_t<Kokkos::Impl::type_list<typename TransformerType<Ts>::type...>>;
104
};
105
106
template
<
template
<
typename
>
typename
TransformerType,
typename
T>
107
using
transform_type_list_t
=
typename
TransformTypeList<TransformerType, T>::type
;
109
112
template
<
typename
>
113
struct
TypeListToTuple
;
114
115
template
<
typename
... Ts>
116
struct
TypeListToTuple
<
Kokkos
::Impl::type_list<Ts...>>
117
{
118
using
type
= std::tuple<Ts...>;
119
};
120
121
template
<
typename
T>
122
using
type_list_to_tuple_t
=
typename
TypeListToTuple<T>::type
;
124
127
template
<
typename
,
typename
>
128
struct
TypeListIndex
;
129
130
template
<
typename
T,
typename
... Ts>
131
struct
TypeListIndex
<T,
Kokkos
::Impl::type_list<T, Ts...>>
132
: std::integral_constant<size_t, 0> {};
133
134
template
<
typename
T,
typename
Head,
typename
... Ts>
135
struct
TypeListIndex
<T,
Kokkos
::Impl::type_list<Head, Ts...>>
136
: std::integral_constant<size_t, 1 + TypeListIndex<T, Kokkos::Impl::type_list<Ts...>>::value> {};
137
138
template
<
typename
T,
typename
S>
139
inline
constexpr
size_t
type_list_index_v
=
TypeListIndex<T, S>::value
;
141
144
template
<
template
<
typename
>
typename
UnaryPred,
typename
...>
145
struct
type_list_all
;
146
148
template
<
template
<
typename
>
typename
UnaryPred,
typename
T,
typename
... Ts>
149
struct
type_list_all
<UnaryPred, T, Ts...>
150
:
public
std::conjunction<UnaryPred<T>, UnaryPred<Ts>...> {};
151
153
template
<
template
<
typename
>
typename
UnaryPred,
typename
... Ts>
154
struct
type_list_all
<UnaryPred,
Kokkos
::Impl::type_list<Ts...>>
155
:
public
std::conjunction<UnaryPred<Ts>...> {};
156
157
template
<
template
<
typename
>
typename
UnaryPred,
typename
... TypeList>
158
inline
constexpr
bool
type_list_all_v
=
type_list_all
<UnaryPred, TypeList...>::value;
160
168
template
<
template
<
typename
>
typename
UnaryPred,
typename
...>
169
struct
type_list_any
;
170
178
#if defined(__NVCC__)
179
template
<
template
<
typename
>
typename
UnaryPred,
typename
T,
typename
... Ts>
180
struct
type_list_any
<UnaryPred, T, Ts...>
181
:
public
std::bool_constant<UnaryPred<T>::value || (UnaryPred<Ts>::value || ...)> {};
182
#else
183
template
<
template
<
typename
>
typename
UnaryPred,
typename
T,
typename
... Ts>
184
struct
type_list_any
<UnaryPred, T, Ts...>
185
:
public
std::disjunction<UnaryPred<T>, UnaryPred<Ts>...> {};
186
#endif
188
196
#if defined(__NVCC__)
197
template
<
template
<
typename
>
typename
UnaryPred,
typename
... Ts>
198
struct
type_list_any
<UnaryPred,
Kokkos
::Impl::type_list<Ts...>>
199
:
public
std::bool_constant<(UnaryPred<Ts>::value || ...)> {};
200
#else
201
template
<
template
<
typename
>
typename
UnaryPred,
typename
... Ts>
202
struct
type_list_any
<UnaryPred,
Kokkos
::Impl::type_list<Ts...>>
203
:
public
std::disjunction<UnaryPred<Ts>...> {};
204
#endif
206
207
template
<
template
<
typename
>
typename
UnaryPred,
typename
... TypeList>
208
inline
constexpr
bool
type_list_any_v
=
type_list_any
<UnaryPred, TypeList...>::value;
210
212
template
<
typename
TypeList,
typename
Callable>
213
constexpr
void
for_each
(Callable callable)
214
{
215
[&] <
size_t
... Is>(std::index_sequence<Is...>)
constexpr
{
216
(callable.template operator()<
type_list_at_t<Is, TypeList>
>(), ...);
217
}(std::make_index_sequence<type_list_size_v<TypeList>>{});
218
}
219
220
}
// namespace Kokkos::utils::impl
221
222
#endif
// KOKKOS_UTILS_IMPL_TYPE_LIST_HPP
Kokkos::utils::impl
Definition
type_list.hpp:13
Kokkos::utils::impl::type_list_all_v
constexpr bool type_list_all_v
Definition
type_list.hpp:158
Kokkos::utils::impl::type_list_size_v
constexpr size_t type_list_size_v
Definition
type_list.hpp:56
Kokkos::utils::impl::type_list_contains_v
constexpr bool type_list_contains_v
Definition
type_list.hpp:73
Kokkos::utils::impl::type_list_any_v
constexpr bool type_list_any_v
Definition
type_list.hpp:208
Kokkos::utils::impl::for_each
constexpr void for_each(Callable callable)
Calls the instantiation of the call operator of a callable object for each type in a Kokkos::Impl::ty...
Definition
type_list.hpp:213
Kokkos::utils::impl::transform_type_list_t
typename TransformTypeList< TransformerType, T >::type transform_type_list_t
Definition
type_list.hpp:107
Kokkos::utils::impl::make_type_list_t
typename make_type_list< Args... >::type make_type_list_t
Definition
type_list.hpp:44
Kokkos::utils::impl::type_list_to_tuple_t
typename TypeListToTuple< T >::type type_list_to_tuple_t
Definition
type_list.hpp:122
Kokkos::utils::impl::is_type_list_v
constexpr bool is_type_list_v
Definition
type_list.hpp:23
Kokkos::utils::impl::type_list_index_v
constexpr size_t type_list_index_v
Definition
type_list.hpp:139
Kokkos::utils::impl::type_list_at_t
typename TypeListAt< I, T >::type type_list_at_t
Definition
type_list.hpp:92
Kokkos
Definition
InsertOp.hpp:9
Kokkos::utils::impl::TransformTypeList< TransformerType, Kokkos::Impl::type_list< Ts... > >::type
Kokkos::Impl::concat_type_list_t< Kokkos::Impl::type_list< typename TransformerType< Ts >::type... > > type
Definition
type_list.hpp:103
Kokkos::utils::impl::TransformTypeList
Definition
type_list.hpp:98
Kokkos::utils::impl::TypeListAt< 0, Kokkos::Impl::type_list< Head, Tail... > >::type
Head type
Definition
type_list.hpp:88
Kokkos::utils::impl::TypeListAt
Definition
type_list.hpp:79
Kokkos::utils::impl::TypeListContains
Definition
type_list.hpp:62
Kokkos::utils::impl::TypeListIndex
Definition
type_list.hpp:128
Kokkos::utils::impl::TypeListSize
Definition
type_list.hpp:50
Kokkos::utils::impl::TypeListToTuple< Kokkos::Impl::type_list< Ts... > >::type
std::tuple< Ts... > type
Definition
type_list.hpp:118
Kokkos::utils::impl::TypeListToTuple
Definition
type_list.hpp:113
Kokkos::utils::impl::is_type_list
Definition
type_list.hpp:17
Kokkos::utils::impl::make_type_list< T, Ts... >::type
Kokkos::Impl::type_list< T, Ts... > type
Definition
type_list.hpp:40
Kokkos::utils::impl::make_type_list< T >::type
T type
Definition
type_list.hpp:34
Kokkos::utils::impl::make_type_list
Definition
type_list.hpp:29
Kokkos::utils::impl::type_list_all
Definition
type_list.hpp:145
Kokkos::utils::impl::type_list_any
Definition
type_list.hpp:169
include
kokkos-utils
impl
type_list.hpp
Generated on
for kokkos-utils by
1.18.0