Skip to content

Commit

Permalink
add structured binding support to GpuTuple
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexanderSinn committed Jun 8, 2024
1 parent d57135e commit d613a75
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion Src/Base/AMReX_Tuple.H
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,23 @@ auto tupleToArray (GpuTuple<T,Ts...> const& tup)
return detail::tuple_to_array_helper(tup, std::index_sequence_for<T,Ts...>{});
}

}
} // namespace amrex

// Spcialize std::tuple_size for GpuTuple. Used by structured bindings.
template<typename... Ts>
struct std::tuple_size<amrex::GpuTuple<Ts...>> {
static constexpr std::size_t value = sizeof...(Ts);
};

// Spcialize std::tuple_element for GpuTuple. Used by structured bindings.
template<typename T, typename... Ts>
struct std::tuple_element<std::size_t{0}, amrex::GpuTuple<T, Ts...>> {
using type = T;
};

template<std::size_t s, typename T, typename... Ts>
struct std::tuple_element<s, amrex::GpuTuple<T, Ts...>> {
using type = typename std::tuple_element<s-1, amrex::GpuTuple<Ts...>>::type;
};

#endif /*AMREX_TUPLE_H_*/

0 comments on commit d613a75

Please sign in to comment.