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>
32constexpr ptrdiff_t dynamic_extent = -1;
34template <ptrdiff_t... ExtentSpecs>
39template <
class Exts, ptrdiff_t NewExtent>
42template <ptrdiff_t... Exts, ptrdiff_t NewExtent>
43struct PrependExtent<Extents<Exts...>, NewExtent> {
44 using type = Extents<NewExtent, Exts...>;
47template <
class Exts, ptrdiff_t NewExtent>
50template <ptrdiff_t... Exts, ptrdiff_t NewExtent>
51struct AppendExtent<Extents<Exts...>, NewExtent> {
52 using type = Extents<Exts..., NewExtent>;
59namespace _parse_view_extents_impl {
62struct _all_remaining_extents_dynamic : std::true_type {};
65struct _all_remaining_extents_dynamic<T*> : _all_remaining_extents_dynamic<T> {
68template <
class T,
unsigned N>
69struct _all_remaining_extents_dynamic<T[N]> : std::false_type {};
71template <
class T,
class Result,
class =
void>
78template <
class T, ptrdiff_t... ExtentSpec>
79struct _parse_impl<T*, Kokkos::Experimental::Extents<ExtentSpec...>,
80 std::enable_if_t<_all_remaining_extents_dynamic<T>::value>>
81 : _parse_impl<T, Kokkos::Experimental::Extents<
82 Kokkos::Experimental::dynamic_extent, ExtentSpec...>> {
86template <
class T, ptrdiff_t... ExtentSpec>
88 T*, Kokkos::Experimental::Extents<ExtentSpec...>,
89 std::enable_if_t<!_all_remaining_extents_dynamic<T>::value>> {
90 using _next = Kokkos::Experimental::AppendExtent<
91 typename _parse_impl<T, Kokkos::Experimental::Extents<ExtentSpec...>,
93 Kokkos::Experimental::dynamic_extent>;
94 using type =
typename _next::type;
97template <
class T, ptrdiff_t... ExtentSpec,
unsigned N>
98struct _parse_impl<T[N], Kokkos::Experimental::Extents<ExtentSpec...>, void>
100 T, Kokkos::Experimental::Extents<ExtentSpec...,
108template <
class DataType>
109struct ParseViewExtents {
110 using type =
typename _parse_view_extents_impl ::_parse_impl<
111 DataType, Kokkos::Experimental::Extents<>>::type;
114template <
class ValueType, ptrdiff_t Ext>
116 using type = ValueType[Ext];
119template <
class ValueType>
120struct ApplyExtent<ValueType, Kokkos::Experimental::dynamic_extent> {
121 using type = ValueType*;
124template <
class ValueType,
unsigned N, ptrdiff_t Ext>
125struct ApplyExtent<ValueType[N], Ext> {
126 using type =
typename ApplyExtent<ValueType, Ext>::type[N];
129template <
class ValueType, ptrdiff_t Ext>
130struct ApplyExtent<ValueType*, Ext> {
131 using type = ValueType * [Ext];
134template <
class ValueType>
135struct ApplyExtent<ValueType*, Kokkos::Experimental::dynamic_extent> {
137 typename ApplyExtent<ValueType,
138 Kokkos::Experimental::dynamic_extent>::type*;
141template <
class ValueType,
unsigned N>
142struct ApplyExtent<ValueType[N], Kokkos::Experimental::dynamic_extent> {
144 typename ApplyExtent<ValueType,
145 Kokkos::Experimental::dynamic_extent>::type[N];