8#include <Kokkos_Macros.hpp>
27 template <std::size_t i, std::size_t N,
typename... Ts>
38 template <std::size_t i, std::size_t N,
typename T,
typename R,
typename... Ts>
46 template <std::
size_t Idx>
48 KOKKOS_INLINE_FUNCTION
auto&
get()
noexcept {
49 if constexpr (Idx == i) {
55 template <std::
size_t Idx>
57 KOKKOS_INLINE_FUNCTION
const auto&
get()
const noexcept {
58 if constexpr (Idx == i) {
65 requires(std::is_copy_assignable_v<T> && std::is_copy_assignable_v<R>
66 && (std::is_copy_assignable_v<Ts> && ...))
69 requires(std::is_move_assignable_v<T> && std::is_move_assignable_v<R>
70 && (std::is_move_assignable_v<Ts> && ...))
73 requires(std::is_copy_constructible_v<T> && std::is_copy_constructible_v<R>
74 && (std::is_copy_constructible_v<Ts> && ...))
77 requires(std::is_move_constructible_v<T> && std::is_move_constructible_v<R>
78 && (std::is_move_constructible_v<Ts> && ...))
82 requires(std::is_default_constructible_v<T> && std::is_default_constructible_v<R>
83 && (std::is_default_constructible_v<Ts> && ...))
85 template <
typename CtorT,
typename CtorR,
typename... CtorTs>
86 KOKKOS_INLINE_FUNCTION
TupleImpl(CtorT&& t, CtorR&& r, CtorTs&&... ts)
88 ,
next(
std::forward<CtorR>(r),
std::forward<CtorTs>(ts)...) {}
97 template <std::
size_t i, std::
size_t N,
typename T>
100 template <std::
size_t Idx>
101 requires(Idx == N - 1)
102 KOKKOS_INLINE_FUNCTION
auto&
get() noexcept {
105 template <std::
size_t Idx>
106 requires(Idx == N - 1)
107 KOKKOS_INLINE_FUNCTION
const auto&
get()
const noexcept {
111 requires(std::is_default_constructible_v<T>)
123 template <
typename... Ts>
129 constexpr static std::size_t
dim =
sizeof...(Ts);
130 constexpr static std::size_t
size =
sizeof...(Ts);
131 template <std::
size_t Idx>
132 requires(Idx <
sizeof...(Ts))
133 KOKKOS_INLINE_FUNCTION
auto&&
get() noexcept {
136 template <std::
size_t Idx>
137 requires(Idx <
sizeof...(Ts))
138 KOKKOS_INLINE_FUNCTION
auto&&
get()
const noexcept {
141 template <
typename Functor, std::size_t Idx,
typename... OtherTs>
143 requires(std::is_copy_assignable_v<Ts> && ...)
148 template <
typename Functor,
typename... OtherTs, std::size_t... Idx>
150 const std::index_sequence<Idx...>&) {
151 int val = (
applySingle<Functor, Idx, OtherTs...>(func, other) ^ ...);
154 template <std::size_t Idx,
typename... OtherTs>
156 requires(std::is_copy_assignable_v<Ts> && ...)
161 template <
typename... OtherTs, std::size_t... Idx>
163 const std::index_sequence<Idx...>&)
164 requires(std::is_copy_assignable_v<Ts> && ...)
169 template <std::size_t Idx,
typename... OtherTs>
171 requires(std::is_move_assignable_v<Ts> && ...)
176 template <
typename... OtherTs, std::size_t... Idx>
178 const std::index_sequence<Idx...>&)
179 requires(std::is_move_assignable_v<Ts> && ...)
181 int val = (
assignToSingle<Idx, OtherTs...>(std::move(other)) ^ ...);
184 template <
typename... OtherTs>
186 requires(std::is_copy_assignable_v<Ts> && ...)
192 template <
typename... OtherTs>
194 requires(std::is_move_assignable_v<Ts> && ...)
196 assignToSequence(std::move(other), std::make_index_sequence<
sizeof...(Ts)>{});
200 requires(std::is_arithmetic_v<Ts> && ...)
203 KOKKOS_LAMBDA(
auto& x,
const auto& y) { x += y; }, other,
204 std::make_index_sequence<
sizeof...(Ts)>{});
208 requires(std::is_arithmetic_v<Ts> && ...)
211 KOKKOS_LAMBDA(
auto& x,
const auto& y) { x -= y; }, other,
212 std::make_index_sequence<
sizeof...(Ts)>{});
216 requires(std::is_arithmetic_v<Ts> && ...)
219 KOKKOS_LAMBDA(
auto& x,
const auto& y) { x *= y; }, other,
220 std::make_index_sequence<
sizeof...(Ts)>{});
224 requires(std::is_arithmetic_v<Ts> && ...)
227 KOKKOS_LAMBDA(
auto& x,
const auto& y) { x /= y; }, other,
228 std::make_index_sequence<
sizeof...(Ts)>{});
232 requires(std::is_arithmetic_v<Ts> && ...)
237 requires(std::is_arithmetic_v<Ts> && ...)
242 requires(std::is_arithmetic_v<Ts> && ...)
247 requires(std::is_arithmetic_v<Ts> && ...)
251 template <std::size_t Idx, std::size_t N,
typename... OtherTs>
253 if constexpr (Idx == N) {
261 template <std::size_t Idx, std::size_t N,
typename... OtherTs>
263 if constexpr (Idx == N) {
270 template <
typename... OtherTs>
272 requires((
sizeof...(Ts) ==
sizeof...(OtherTs)) && (std::totally_ordered<Ts> && ...))
276 template <
typename... OtherTs>
278 requires((
sizeof...(Ts) ==
sizeof...(OtherTs)) && (std::totally_ordered<Ts> && ...))
283 requires(std::is_copy_assignable_v<Ts> && ...)
287 requires(std::is_move_assignable_v<Ts> && ...)
291 requires(std::is_copy_constructible_v<Ts> && ...)
294 requires(std::is_move_constructible_v<Ts> && ...)
298 requires(std::is_default_constructible_v<Ts> && ...)
300 template <
typename... CtorTs>
301 requires(std::constructible_from<Ts, CtorTs> && ...)
302 KOKKOS_INLINE_FUNCTION
Tuple(CtorTs&&... args)
313 template <std::size_t Idx,
typename... Ts>
325 template <std::size_t Idx,
typename... Ts>
336 template <
typename... Ts>
338 return Tuple<Ts...>(std::forward<Ts>(args)...);
340 template <std::size_t Idx,
typename T,
typename... Ts>
344 template <
typename T,
typename... Ts>
348 template <std::size_t Idx,
typename... Ts>
353 template <
typename... Ts>
354 struct tuple_size<::
ippl::Tuple<Ts...>> : std::integral_constant<size_t, sizeof...(Ts)> {};
356 template <
size_t Idx,
typename... Ts>
358 using type = typename ::ippl::TupleType<Idx, Ts...>;
361 template <
size_t Idx,
typename... Ts>
365 template <
size_t Idx,
typename... Ts>
366 KOKKOS_INLINE_FUNCTION
const auto&
get(const ::ippl::Tuple<Ts...>& t) {
KOKKOS_INLINE_FUNCTION auto & get(::ippl::Tuple< Ts... > &t)
KOKKOS_INLINE_FUNCTION Tuple< Ts... > makeTuple(Ts &&... args)
Function to create a Tuple with specified elements.
typename TupleTypeImpl< Idx, Ts... >::type TupleType
KOKKOS_INLINE_FUNCTION auto & get(Tuple< Ts... > &t)
Accessor function to get an element mutable reference at a specific index from a Tuple.
Implementation details for the Tuple class.
TupleImpl(TupleImpl< i, N, T, R, Ts... > &&t)=default
KOKKOS_INLINE_FUNCTION auto & get() noexcept
TupleImpl(const TupleImpl< i, N, T, R, Ts... > &t)=default
TupleImpl & operator=(const TupleImpl< i, N, T, R, Ts... > &t)=default
KOKKOS_INLINE_FUNCTION TupleImpl(CtorT &&t, CtorR &&r, CtorTs &&... ts)
TupleImpl< i+1, N, R, Ts... > next
Remaining tuple elements: next doesn't have typename T anymore.
TupleImpl & operator=(TupleImpl< i, N, T, R, Ts... > &&t)=default
KOKKOS_INLINE_FUNCTION const auto & get() const noexcept
KOKKOS_INLINE_FUNCTION TupleImpl(T &&t)
KOKKOS_INLINE_FUNCTION auto & get() noexcept
KOKKOS_INLINE_FUNCTION const auto & get() const noexcept
KOKKOS_INLINE_FUNCTION TupleImpl(const T &t)
Generic tuple class with various operations.
KOKKOS_INLINE_FUNCTION void assignToSequence(const Tuple< OtherTs... > &other, const std::index_sequence< Idx... > &)
KOKKOS_INLINE_FUNCTION Tuple & operator=(const Tuple< OtherTs... > &other)
KOKKOS_INLINE_FUNCTION int applySingle(Functor func, const Tuple< OtherTs... > &other)
KOKKOS_INLINE_FUNCTION int assignToSingle(Tuple< OtherTs... > &&other)
KOKKOS_INLINE_FUNCTION Tuple operator/(const Tuple &other) const
Tuple(Tuple< Ts... > &&t)=default
KOKKOS_INLINE_FUNCTION bool operator==(const Tuple< OtherTs... > &other) const
Tuple(const Tuple< Ts... > &t)=default
KOKKOS_INLINE_FUNCTION Tuple operator-(const Tuple &other) const
KOKKOS_INLINE_FUNCTION int assignToSingle(const Tuple< OtherTs... > &other)
KOKKOS_INLINE_FUNCTION Tuple operator*(const Tuple &other) const
KOKKOS_INLINE_FUNCTION void assignToSequence(Tuple< OtherTs... > &&other, const std::index_sequence< Idx... > &)
KOKKOS_INLINE_FUNCTION auto && get() const noexcept
Tuple & operator=(Tuple< Ts... > &&other)=default
KOKKOS_INLINE_FUNCTION bool lexicographicalLess(const Tuple &other) const
KOKKOS_INLINE_FUNCTION Tuple & operator*=(const Tuple &other)
KOKKOS_INLINE_FUNCTION Tuple & operator+=(const Tuple &other)
KOKKOS_INLINE_FUNCTION void applySequence(Functor func, const Tuple< OtherTs... > &other, const std::index_sequence< Idx... > &)
KOKKOS_INLINE_FUNCTION auto && get() noexcept
KOKKOS_INLINE_FUNCTION Tuple operator+(const Tuple &other) const
static constexpr std::size_t size
KOKKOS_INLINE_FUNCTION bool operator<(const Tuple< OtherTs... > &other) const
TupleImpl< 0, sizeof...(Ts), Ts... > tupleImpl_m
static constexpr std::size_t dim
KOKKOS_INLINE_FUNCTION bool lexicographicalEquals(const Tuple &other) const
Tuple & operator=(const Tuple< Ts... > &other)=default
KOKKOS_INLINE_FUNCTION Tuple & operator=(Tuple< OtherTs... > &&other)
KOKKOS_INLINE_FUNCTION Tuple & operator/=(const Tuple &other)
KOKKOS_INLINE_FUNCTION Tuple & operator-=(const Tuple &other)
TupleTypeImpl< Idx - 1, Ts... > type
typename ::ippl::TupleType< Idx, Ts... > type