7#include <Kokkos_Core.hpp>
27template<
typename ValueType>
28class View :
public std::span<ValueType>
32 using base = std::span<ValueType>;
45 using std::span<ValueType>::span;
49 KOKKOS_INLINE_FUNCTION
50 View(std::span<ValueType> in) :
View(in.begin(), in.end()) {}
58 KOKKOS_INLINE_FUNCTION
62 if (index < 0 ||
static_cast<sizeType>(index) >= this->
size())
66 Kokkos::abort(
"Index is out of range.");
70 return std::span<ValueType>::operator[](
static_cast<sizeType>(index));
74 return std::span<ValueType>::operator[](
static_cast<sizeType>(index));
77 KOKKOS_INLINE_FUNCTION
80 KOKKOS_INLINE_FUNCTION
83 return base::subspan(
static_cast<sizeType>(start),
static_cast<sizeType>(length));
86 KOKKOS_INLINE_FUNCTION
89 return base::subspan(
static_cast<sizeType>(start));
99 requires(Type& inst) { inst.view(); } ||
requires(
const Type& inst) { inst.view(); };
106template<
typename... Types>
107 requires(hasView<std::remove_reference_t<Types>> && ...)
110 return std::tuple(args.view()...);
std::span< ValueType > base
KOKKOS_INLINE_FUNCTION View< ValueType > subview(localIdx start, localIdx length) const
KOKKOS_INLINE_FUNCTION sizeType size() const
KOKKOS_INLINE_FUNCTION View(std::span< ValueType > in)
KOKKOS_INLINE_FUNCTION View< ValueType > subview(localIdx start) const
KOKKOS_INLINE_FUNCTION constexpr ValueType & operator[](localIdx index) const
Concept, for any type which has the 'view' method.
Integer types used throughout NeoN.
auto views(Types &... args)
Unpacks all views of the passed classes.