44 #ifndef KOKKOS_KOKKOS_EXTENTS_HPP
45 #define KOKKOS_KOKKOS_EXTENTS_HPP
50 namespace Experimental {
52 constexpr ptrdiff_t dynamic_extent = -1;
54 template <ptrdiff_t... ExtentSpecs>
59 template <
class Exts, ptrdiff_t NewExtent>
62 template <ptrdiff_t... Exts, ptrdiff_t NewExtent>
63 struct PrependExtent<Extents<Exts...>, NewExtent> {
64 using type = Extents<NewExtent, Exts...>;
67 template <
class Exts, ptrdiff_t NewExtent>
70 template <ptrdiff_t... Exts, ptrdiff_t NewExtent>
71 struct AppendExtent<Extents<Exts...>, NewExtent> {
72 using type = Extents<Exts..., NewExtent>;
79 namespace _parse_view_extents_impl {
82 struct _all_remaining_extents_dynamic : std::true_type {};
85 struct _all_remaining_extents_dynamic<T*> : _all_remaining_extents_dynamic<T> {
88 template <
class T,
unsigned N>
89 struct _all_remaining_extents_dynamic<T[N]> : std::false_type {};
91 template <
class T,
class Result,
class =
void>
98 template <
class T, ptrdiff_t... ExtentSpec>
100 T*, Kokkos::Experimental::Extents<ExtentSpec...>,
101 typename std::enable_if<_all_remaining_extents_dynamic<T>::value>::type>
102 : _parse_impl<T, Kokkos::Experimental::Extents<
103 Kokkos::Experimental::dynamic_extent, ExtentSpec...>> {
107 template <
class T, ptrdiff_t... ExtentSpec>
109 T*, Kokkos::Experimental::Extents<ExtentSpec...>,
110 typename std::enable_if<!_all_remaining_extents_dynamic<T>::value>::type> {
111 using _next = Kokkos::Experimental::AppendExtent<
112 typename _parse_impl<T, Kokkos::Experimental::Extents<ExtentSpec...>,
114 Kokkos::Experimental::dynamic_extent>;
115 using type =
typename _next::type;
118 template <
class T, ptrdiff_t... ExtentSpec,
unsigned N>
119 struct _parse_impl<T[N], Kokkos::Experimental::Extents<ExtentSpec...>, void>
121 T, Kokkos::Experimental::Extents<ExtentSpec...,
129 template <
class DataType>
130 struct ParseViewExtents {
131 using type =
typename _parse_view_extents_impl ::_parse_impl<
132 DataType, Kokkos::Experimental::Extents<>>::type;
135 template <
class ValueType, ptrdiff_t Ext>
137 using type = ValueType[Ext];
140 template <
class ValueType>
141 struct ApplyExtent<ValueType, Kokkos::Experimental::dynamic_extent> {
142 using type = ValueType*;
145 template <
class ValueType,
unsigned N, ptrdiff_t Ext>
146 struct ApplyExtent<ValueType[N], Ext> {
147 using type =
typename ApplyExtent<ValueType, Ext>::type[N];
150 template <
class ValueType, ptrdiff_t Ext>
151 struct ApplyExtent<ValueType*, Ext> {
152 using type = ValueType * [Ext];
155 template <
class ValueType>
156 struct ApplyExtent<ValueType*, Kokkos::Experimental::dynamic_extent> {
158 typename ApplyExtent<ValueType,
159 Kokkos::Experimental::dynamic_extent>::type*;
162 template <
class ValueType,
unsigned N>
163 struct ApplyExtent<ValueType[N], Kokkos::Experimental::dynamic_extent> {
165 typename ApplyExtent<ValueType,
166 Kokkos::Experimental::dynamic_extent>::type[N];
173 #endif // KOKKOS_KOKKOS_EXTENTS_HPP