17#ifndef KOKKOS_IMPL_PUBLIC_INCLUDE
18#include <Kokkos_Macros.hpp>
20 "Including non-public Kokkos header files is not allowed.");
22#ifndef KOKKOS_KOKKOS_EXTENTS_HPP
23#define KOKKOS_KOKKOS_EXTENTS_HPP
27#include <Kokkos_Macros.hpp>
28#ifdef KOKKOS_ENABLE_IMPL_MDSPAN
29#include <mdspan/mdspan.hpp>
36#ifndef KOKKOS_ENABLE_IMPL_MDSPAN
37constexpr size_t dynamic_extent = std::numeric_limits<size_t>::max();
42template <
size_t... ExtentSpecs>
47template <
class Exts,
size_t NewExtent>
50template <
size_t... Exts,
size_t NewExtent>
51struct PrependExtent<Extents<Exts...>, NewExtent> {
52 using type = Extents<NewExtent, Exts...>;
55template <
class Exts,
size_t NewExtent>
58template <
size_t... Exts,
size_t NewExtent>
59struct AppendExtent<Extents<Exts...>, NewExtent> {
60 using type = Extents<Exts..., NewExtent>;
66namespace _parse_view_extents_impl {
69struct _all_remaining_extents_dynamic : std::true_type {};
72struct _all_remaining_extents_dynamic<T*> : _all_remaining_extents_dynamic<T> {
75template <
class T,
unsigned N>
76struct _all_remaining_extents_dynamic<T[N]> : std::false_type {};
78template <
class T,
class Result,
class =
void>
85template <
class T,
size_t... ExtentSpec>
86struct _parse_impl<T*, Kokkos::Experimental::Extents<ExtentSpec...>,
87 std::enable_if_t<_all_remaining_extents_dynamic<T>::value>>
88 : _parse_impl<T, Kokkos::Experimental::Extents<Kokkos::dynamic_extent,
92template <
class T,
size_t... ExtentSpec>
94 T*, Kokkos::Experimental::Extents<ExtentSpec...>,
95 std::enable_if_t<!_all_remaining_extents_dynamic<T>::value>> {
96 using _next = Kokkos::Experimental::AppendExtent<
97 typename _parse_impl<T, Kokkos::Experimental::Extents<ExtentSpec...>,
99 Kokkos::dynamic_extent>;
100 using type =
typename _next::type;
103template <
class T,
size_t... ExtentSpec,
unsigned N>
104struct _parse_impl<T[N], Kokkos::Experimental::Extents<ExtentSpec...>, void>
106 Kokkos::Experimental::Extents<ExtentSpec...,
114template <
class DataType>
115struct ParseViewExtents {
116 using type =
typename _parse_view_extents_impl ::_parse_impl<
117 DataType, Kokkos::Experimental::Extents<>>::type;
120template <
class ValueType,
size_t Ext>
122 using type = ValueType[Ext];
125template <
class ValueType>
126struct ApplyExtent<ValueType, Kokkos::dynamic_extent> {
127 using type = ValueType*;
130template <
class ValueType,
unsigned N,
size_t Ext>
131struct ApplyExtent<ValueType[N], Ext> {
132 using type =
typename ApplyExtent<ValueType, Ext>::type[N];
135template <
class ValueType,
size_t Ext>
136struct ApplyExtent<ValueType*, Ext> {
137 using type = ValueType* [Ext];
140template <
class ValueType>
141struct ApplyExtent<ValueType*, dynamic_extent> {
142 using type =
typename ApplyExtent<ValueType, dynamic_extent>::type*;
145template <
class ValueType,
unsigned N>
146struct ApplyExtent<ValueType[N], dynamic_extent> {
147 using type =
typename ApplyExtent<ValueType, dynamic_extent>::type[N];