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
26 #include <type_traits>
27 #include <Kokkos_Macros.hpp>
30 namespace Experimental {
32 constexpr ptrdiff_t dynamic_extent = -1;
34 template <ptrdiff_t... ExtentSpecs>
39 template <
class Exts, ptrdiff_t NewExtent>
42 template <ptrdiff_t... Exts, ptrdiff_t NewExtent>
43 struct PrependExtent<Extents<Exts...>, NewExtent> {
44 using type = Extents<NewExtent, Exts...>;
47 template <
class Exts, ptrdiff_t NewExtent>
50 template <ptrdiff_t... Exts, ptrdiff_t NewExtent>
51 struct AppendExtent<Extents<Exts...>, NewExtent> {
52 using type = Extents<Exts..., NewExtent>;
59 namespace _parse_view_extents_impl {
62 struct _all_remaining_extents_dynamic : std::true_type {};
65 struct _all_remaining_extents_dynamic<T*> : _all_remaining_extents_dynamic<T> {
68 template <
class T,
unsigned N>
69 struct _all_remaining_extents_dynamic<T[N]> : std::false_type {};
71 template <
class T,
class Result,
class =
void>
78 template <
class T, ptrdiff_t... ExtentSpec>
79 struct _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...>> {
86 template <
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;
97 template <
class T, ptrdiff_t... ExtentSpec,
unsigned N>
98 struct _parse_impl<T[N], Kokkos::Experimental::Extents<ExtentSpec...>, void>
100 T, Kokkos::Experimental::Extents<ExtentSpec...,
108 template <
class DataType>
109 struct ParseViewExtents {
110 using type =
typename _parse_view_extents_impl ::_parse_impl<
111 DataType, Kokkos::Experimental::Extents<>>::type;
114 template <
class ValueType, ptrdiff_t Ext>
116 using type = ValueType[Ext];
119 template <
class ValueType>
120 struct ApplyExtent<ValueType, Kokkos::Experimental::dynamic_extent> {
121 using type = ValueType*;
124 template <
class ValueType,
unsigned N, ptrdiff_t Ext>
125 struct ApplyExtent<ValueType[N], Ext> {
126 using type =
typename ApplyExtent<ValueType, Ext>::type[N];
129 template <
class ValueType, ptrdiff_t Ext>
130 struct ApplyExtent<ValueType*, Ext> {
131 using type = ValueType * [Ext];
134 template <
class ValueType>
135 struct ApplyExtent<ValueType*, Kokkos::Experimental::dynamic_extent> {
137 typename ApplyExtent<ValueType,
138 Kokkos::Experimental::dynamic_extent>::type*;
141 template <
class ValueType,
unsigned N>
142 struct ApplyExtent<ValueType[N], Kokkos::Experimental::dynamic_extent> {
144 typename ApplyExtent<ValueType,
145 Kokkos::Experimental::dynamic_extent>::type[N];
152 #endif // KOKKOS_KOKKOS_EXTENTS_HPP