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