44#ifndef KOKKOS_KOKKOS_EXTENTS_HPP
45#define KOKKOS_KOKKOS_EXTENTS_HPP
49#include <Kokkos_Macros.hpp>
54constexpr ptrdiff_t dynamic_extent = -1;
56template <ptrdiff_t... ExtentSpecs>
61template <
class Exts, ptrdiff_t NewExtent>
64template <ptrdiff_t... Exts, ptrdiff_t NewExtent>
65struct PrependExtent<Extents<Exts...>, NewExtent> {
66 using type = Extents<NewExtent, Exts...>;
69template <
class Exts, ptrdiff_t NewExtent>
72template <ptrdiff_t... Exts, ptrdiff_t NewExtent>
73struct AppendExtent<Extents<Exts...>, NewExtent> {
74 using type = Extents<Exts..., NewExtent>;
81namespace _parse_view_extents_impl {
84struct _all_remaining_extents_dynamic : std::true_type {};
87struct _all_remaining_extents_dynamic<T*> : _all_remaining_extents_dynamic<T> {
90template <
class T,
unsigned N>
91struct _all_remaining_extents_dynamic<T[N]> : std::false_type {};
93template <
class T,
class Result,
class =
void>
100template <
class T, ptrdiff_t... ExtentSpec>
102 T*, Kokkos::Experimental::Extents<ExtentSpec...>,
103 typename std::enable_if<_all_remaining_extents_dynamic<T>::value>::type>
104 : _parse_impl<T, Kokkos::Experimental::Extents<
105 Kokkos::Experimental::dynamic_extent, ExtentSpec...>> {
109template <
class T, ptrdiff_t... ExtentSpec>
111 T*, Kokkos::Experimental::Extents<ExtentSpec...>,
112 typename std::enable_if<!_all_remaining_extents_dynamic<T>::value>::type> {
113 using _next = Kokkos::Experimental::AppendExtent<
114 typename _parse_impl<T, Kokkos::Experimental::Extents<ExtentSpec...>,
116 Kokkos::Experimental::dynamic_extent>;
117 using type =
typename _next::type;
120template <
class T, ptrdiff_t... ExtentSpec,
unsigned N>
121struct _parse_impl<T[N], Kokkos::Experimental::Extents<ExtentSpec...>, void>
123 T, Kokkos::Experimental::Extents<ExtentSpec...,
131template <
class DataType>
132struct ParseViewExtents {
133 using type =
typename _parse_view_extents_impl ::_parse_impl<
134 DataType, Kokkos::Experimental::Extents<>>::type;
137template <
class ValueType, ptrdiff_t Ext>
139 using type = ValueType[Ext];
142template <
class ValueType>
143struct ApplyExtent<ValueType, Kokkos::Experimental::dynamic_extent> {
144 using type = ValueType*;
147template <
class ValueType,
unsigned N, ptrdiff_t Ext>
148struct ApplyExtent<ValueType[N], Ext> {
149 using type =
typename ApplyExtent<ValueType, Ext>::type[N];
152template <
class ValueType, ptrdiff_t Ext>
153struct ApplyExtent<ValueType*, Ext> {
154 using type = ValueType * [Ext];
157template <
class ValueType>
158struct ApplyExtent<ValueType*, Kokkos::Experimental::dynamic_extent> {
160 typename ApplyExtent<ValueType,
161 Kokkos::Experimental::dynamic_extent>::type*;
164template <
class ValueType,
unsigned N>
165struct ApplyExtent<ValueType[N], Kokkos::Experimental::dynamic_extent> {
167 typename ApplyExtent<ValueType,
168 Kokkos::Experimental::dynamic_extent>::type[N];