7#include <Kokkos_Core.hpp>
26template<
typename ValueType>
27class View :
public std::span<ValueType>
31 using base = std::span<ValueType>;
44 using std::span<ValueType>::span;
48 KOKKOS_INLINE_FUNCTION
49 View(std::span<ValueType> in) :
View(in.begin(), in.end()) {}
57 KOKKOS_INLINE_FUNCTION
61 if (index < 0 || index >= this->
size())
65 Kokkos::abort(
"Index is out of range.");
69 return std::span<ValueType>::operator[](
static_cast<size_t>(index));
73 return std::span<ValueType>::operator[](
static_cast<size_t>(index));
76 KOKKOS_INLINE_FUNCTION
79 KOKKOS_INLINE_FUNCTION
82 return base::subspan(
static_cast<size_t>(start),
static_cast<size_t>(length));
85 KOKKOS_INLINE_FUNCTION
88 return base::subspan(
static_cast<size_t>(start));
98 requires(Type& inst) { inst.view(); } ||
requires(
const Type& inst) { inst.view(); };
105template<
typename... Types>
106 requires(hasView<std::remove_reference_t<Types>> && ...)
109 return std::tuple(args.view()...);
std::span< ValueType > base
KOKKOS_INLINE_FUNCTION View< ValueType > subview(localIdx start, localIdx length) const
KOKKOS_INLINE_FUNCTION View(std::span< ValueType > in)
KOKKOS_INLINE_FUNCTION View< ValueType > subview(localIdx start) const
KOKKOS_INLINE_FUNCTION localIdx size() 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.