21 template<
typename X,
typename T_Tuple>
24 static_assert(
sizeof(T_Tuple) &&
false);
27 template<
typename X,
template<
typename...>
typename T_Tuple,
typename... T>
28 struct KeyIdx<X, T_Tuple<T...>>
30 template<std::size_t... idx>
31 static constexpr ssize_t find_idx(std::index_sequence<idx...>)
33 ssize_t found_idx = -1;
35 [[maybe_unused]]
bool notUsed
36 = ((std::is_same_v<X, typename T::KeyType> && (found_idx = idx,
true)) || ...);
41 static constexpr ssize_t value = find_idx(std::index_sequence_for<T...>{});
44 template<
typename X,
template<
typename...>
typename T_Tuple>
45 class KeyIdx<X, T_Tuple<>>
47 static constexpr ssize_t find_idx(std::index_sequence<>)
53 static constexpr ssize_t value = find_idx(std::index_sequence_for<>{});
57 template<
typename T_Key,
typename T_Tuple>
58 inline consteval ssize_t
getIdx(T_Tuple&&, T_Key
const& = T_Key{})
60 constexpr auto idx = internal::KeyIdx<T_Key, std::decay_t<T_Tuple>>::value;
64 template<
typename T_Key,
typename T_Tuple>
65 consteval bool hasTag(T_Tuple&&, T_Key
const& = T_Key{})
67 constexpr auto idx = internal::KeyIdx<T_Key, std::decay_t<T_Tuple>>::value;
71 template<
typename T_Key,
typename T_Tuple>
72 inline constexpr decltype(
auto)
getTag(T_Tuple&& t, T_Key
const& = T_Key{})
74 constexpr auto idx = internal::KeyIdx<T_Key, std::decay_t<T_Tuple>>::value;
75 static_assert(idx != -1,
"Member in dict missing!");
76 static_assert(idx < std::tuple_size_v<std::decay_t<T_Tuple>>,
"index out of range!");
80 template<
typename T_Key,
typename T_Value>
97 template<
typename T_Object,
typename T_Sfinae =
void>
101 static constexpr auto get(T&& data)
103 return std::forward<T>(data);
108 template<
typename... T_DictEntry>
111 static_assert(
sizeof...(T_DictEntry) &&
false);
114 template<
typename... T_Keys,
typename... T_Values>
131 static constexpr auto makeDict()
requires(std::default_initializable<T_Values>, ...)
143 constexpr decltype(
auto)
operator[](
auto const tag)
const
145 return getTag(*
this, tag);
149 constexpr decltype(
auto)
operator[](
auto const tag)
151 return getTag(*
this, tag);
155 template<
size_t T_
idx>
161 template<
size_t T_
idx>
168 template<
typename... T_Keys,
typename... T_Values>
171 template<
typename... T_Keys,
typename... T_Values>
177 template<
typename... T_Keys,
typename... T_Values>
178 struct tuple_size<
alpaka::Dict<alpaka::DictEntry<T_Keys, T_Values>...>>
180 static constexpr std::size_t value =
sizeof...(T_Keys);
183 template<std::size_t I,
typename... T_Keys,
typename... T_Values>
184 struct tuple_element<I,
alpaka::
Dict<alpaka::DictEntry<T_Keys, T_Values>...>>
193 template<std::size_t... idx0, std::size_t... idx1,
typename T_Dict0,
typename T_Dict1>
195 std::index_sequence<idx0...>,
196 std::index_sequence<idx1...>,
203 template<
typename... T_Entries0,
typename... T_Entries1>
207 std::index_sequence_for<T_Entries0...>{},
208 std::index_sequence_for<T_Entries1...>{},
213 template<
bool condition,
typename... T_Entries0,
typename... T_Entries1>
214 requires(condition ==
true)
218 std::index_sequence_for<T_Entries0...>{},
219 std::index_sequence_for<T_Entries1...>{},
224 template<
bool condition,
typename... T_Entries0,
typename... T_Entries1>
225 requires(condition ==
false)
228 alpaka::unused(dict1);
#define ALPAKA_FN_HOST_ACC
All functions that can be used on an accelerator have to be attributed with ALPAKA_FN_ACC or ALPAKA_F...
#define ALPAKA_TYPEOF(...)
Get the type of instance.
#define ALPAKA_NO_HOST_ACC_WARNING
Disable nvcc warning: 'calling a host function from host device function.' Usage: ALPAKA_NO_HOST_ACC_...
Validates if T is a specialization of the unspecialized template type U.
constexpr auto conditionalAppendDict(Dict< T_Entries0... > const &dict0, Dict< T_Entries1... > const &dict1)
consteval bool hasTag(T_Tuple &&, T_Key const &=T_Key{})
constexpr decltype(auto) unWrapp(T &&value)
constexpr auto makeTuple(auto &&... args)
constexpr auto joinDictHelper(std::index_sequence< idx0... >, std::index_sequence< idx1... >, T_Dict0 dict0, T_Dict1 dict1)
constexpr auto joinDict(Dict< T_Entries0... > const &dict0, Dict< T_Entries1... > const &dict1)
ALPAKA_FN_HOST_ACC Dict(Tuple< DictEntry< T_Keys, T_Values >... > const &) -> Dict< DictEntry< T_Keys, T_Values >... >
constexpr decltype(auto) getTag(T_Tuple &&t, T_Key const &=T_Key{})
constexpr decltype(auto) get(concepts::SpecializationOf< Dict > auto &t) noexcept
Tuple(T_Args &&...) -> Tuple< T_Args... >
consteval ssize_t getIdx(T_Tuple &&, T_Key const &=T_Key{})
constexpr DictEntry(T_Key const, T_Value const &v)
constexpr DictEntry()=default
constexpr Dict(DictEntry< T_Keys, T_Values > const &... dictEntries)
constexpr Dict(Dict const &)=default
constexpr Dict(Dict &&)=default
Tuple< DictEntry< T_Keys, T_Values >... > TupleType
constexpr Dict(Tuple< DictEntry< T_Keys, T_Values >... > const &data)
static constexpr auto makeDict()
static constexpr bool hasKey(auto key)
basic tuple implementation
constexpr Tuple(T_CArgs &&... us) noexcept((std::is_nothrow_constructible_v< T_Args, T_CArgs && > &&...))
static constexpr auto get(T &&data)