1#ifndef AMREX_TYPELIST_H_
2#define AMREX_TYPELIST_H_
3#include <AMReX_Config.H>
15 static constexpr std::size_t
size () noexcept {
return sizeof...(Ts); }
20 template <std::
size_t I,
typename T>
struct TypeListGet;
22 template <std::size_t I,
typename Head,
typename... Tail>
23 struct TypeListGet<I, TypeList<Head, Tail...> >
24 : TypeListGet<I-1, TypeList<Tail...> > {};
26 template <
typename Head,
typename... Tail>
27 struct TypeListGet<0, TypeList<Head, Tail...> > {
34template <std::
size_t I,
typename T>
35using TypeAt =
typename detail::TypeListGet<I,T>::type;
40 template <
typename TL,
typename F, std::size_t...N>
41 constexpr void for_each_impl (
F const&f, std::index_sequence<N...>)
46 template <
typename TL,
typename F, std::size_t...N>
47 constexpr bool for_each_until_impl (
F const&f, std::index_sequence<N...>)
81template <
typename... Ts,
typename F>
85 detail::for_each_impl<
TypeList<Ts...>>
86 (std::forward<F>(f), std::make_index_sequence<
sizeof...(Ts)>());
118template <
typename... Ts,
typename F>
122 return detail::for_each_until_impl<
TypeList<Ts...>>
123 (std::forward<F>(f), std::make_index_sequence<
sizeof...(Ts)>());
127template <
typename... As,
typename... Bs>
132template <
typename... Ls,
typename A>
137template <
typename LLs,
typename... As>
154template <
typename... Ls>
159template <
class T, std::
size_t N>
162 static constexpr std::size_t
size () noexcept {
return N; }
168 template <
class T, std::
size_t N>
169 constexpr auto SingleTypeMultiplier_impl () {
170 if constexpr (N == 0) {
172 }
else if constexpr (N == 1) {
173 return TypeList<T>{};
174 }
else if constexpr (N % 2 == 0) {
175 return SingleTypeMultiplier_impl<T, N / 2>() + SingleTypeMultiplier_impl<T, N / 2>();
177 return SingleTypeMultiplier_impl<T, N - 1>() + TypeList<T>{};
183 template <
class T, std::
size_t N>
184 constexpr auto SingleTypeMultiplier (
const T (&)[N]) {
185 return SingleTypeMultiplier_impl<T, N>();
191 template <
class T, std::
size_t N>
192 constexpr auto SingleTypeMultiplier (TypeArray<T, N>) {
193 return SingleTypeMultiplier_impl<T, N>();
198 constexpr auto SingleTypeMultiplier (T) {
199 return TypeList<T>{};
203 template <
template <
class...>
class TParam,
class... Args>
204 constexpr auto TApply (TypeList<Args...>) {
205 return TypeList<TParam<Args...>>{};
218template <
template <
class...>
class TParam,
class... Types>
220 (
TypeList<>{} + ... + detail::SingleTypeMultiplier(std::declval<Types>()))
229template <
typename... Ts>
Definition AMReX_Amr.cpp:49
typename detail::TypeListGet< I, T >::type TypeAt
Type at position I of a TypeList.
Definition AMReX_TypeList.H:35
__host__ __device__ GpuComplex< T > operator*(const GpuComplex< T > &a_x, const GpuComplex< U > &a_y) noexcept
Multiply two complex numbers.
Definition AMReX_GpuComplex.H:257
typename ToTypeList< T >::type ToTypeList_t
Definition AMReX_TypeList.H:233
constexpr bool IsTypeList_v
Definition AMReX_TypeList.H:237
constexpr auto CartesianProduct(Ls...)
Cartesian Product of TypeLists.
Definition AMReX_TypeList.H:155
constexpr auto single_product(TypeList< Ls... >, A)
Definition AMReX_TypeList.H:133
constexpr void ForEach(TypeList< Ts... >, F &&f)
For each type t in TypeList, call f(t)
Definition AMReX_TypeList.H:83
constexpr bool ForEachUntil(TypeList< Ts... >, F &&f)
For each type t in TypeList, call f(t) until true is returned.
Definition AMReX_TypeList.H:120
TypeAt< 0, decltype(detail::TApply< TParam >((TypeList<>{}+...+detail::SingleTypeMultiplier(std::declval< Types >()))))> TypeMultiplier
Return the first template argument with the later arguments applied to it. Types of the form T[N] are...
Definition AMReX_TypeList.H:221
__host__ __device__ XDim3 operator+(XDim3 const &a, XDim3 const &b)
Definition AMReX_Dim3.H:28
Definition AMReX_TypeList.H:235
Wrap non-TypeList into TypeList.
Definition AMReX_TypeList.H:227
Definition AMReX_TypeList.H:160
static constexpr std::size_t size() noexcept
Definition AMReX_TypeList.H:162
T Type
Definition AMReX_TypeList.H:161
Struct for holding types.
Definition AMReX_TypeList.H:13
static constexpr std::size_t size() noexcept
Number of types in the TypeList.
Definition AMReX_TypeList.H:15