@@ -55,37 +55,6 @@ template <class OffsetType, class ExtentType, class StrideType>
5555struct is_strided_slice <
5656 strided_slice<OffsetType, ExtentType, StrideType>> : std::true_type {};
5757
58- // Helper for identifying valid pair like things
59- template <class T , class IndexType > struct index_pair_like : std::false_type {};
60-
61- template <class IdxT1 , class IdxT2 , class IndexType >
62- struct index_pair_like <std::pair<IdxT1, IdxT2>, IndexType> {
63- static constexpr bool value = std::is_convertible_v<IdxT1, IndexType> &&
64- std::is_convertible_v<IdxT2, IndexType>;
65- };
66-
67- template <class IdxT1 , class IdxT2 , class IndexType >
68- struct index_pair_like <std::tuple<IdxT1, IdxT2>, IndexType> {
69- static constexpr bool value = std::is_convertible_v<IdxT1, IndexType> &&
70- std::is_convertible_v<IdxT2, IndexType>;
71- };
72-
73- template <class IdxT1 , class IdxT2 , class IndexType >
74- struct index_pair_like <tuple<IdxT1, IdxT2>, IndexType> {
75- static constexpr bool value = std::is_convertible_v<IdxT1, IndexType> &&
76- std::is_convertible_v<IdxT2, IndexType>;
77- };
78-
79- template <class IdxT , class IndexType >
80- struct index_pair_like <std::complex <IdxT>, IndexType> {
81- static constexpr bool value = std::is_convertible_v<IdxT, IndexType>;
82- };
83-
84- template <class IdxT , class IndexType >
85- struct index_pair_like <std::array<IdxT, 2 >, IndexType> {
86- static constexpr bool value = std::is_convertible_v<IdxT, IndexType>;
87- };
88-
8958// first_of(slice): getting begin of slice specifier range
9059MDSPAN_TEMPLATE_REQUIRES (
9160 class Integral ,
@@ -98,8 +67,8 @@ constexpr Integral first_of(const Integral &i) {
9867
9968template <class Integral , Integral v>
10069MDSPAN_INLINE_FUNCTION
101- constexpr Integral first_of (const std::integral_constant<Integral, v >&) {
102- return integral_constant<Integral, v >();
70+ constexpr auto first_of (const constant_wrapper<v, Integral >&) {
71+ return constant_wrapper<v, Integral >();
10372}
10473
10574MDSPAN_INLINE_FUNCTION
@@ -108,38 +77,6 @@ first_of(const ::MDSPAN_IMPL_STANDARD_NAMESPACE::full_extent_t &) {
10877 return integral_constant<size_t , 0 >();
10978}
11079
111- MDSPAN_TEMPLATE_REQUIRES (
112- class Slice ,
113- /* requires */ (index_pair_like<Slice, size_t >::value)
114- )
115- MDSPAN_INLINE_FUNCTION
116- constexpr auto first_of (const Slice &i) {
117- return get<0 >(i);
118- }
119-
120- MDSPAN_TEMPLATE_REQUIRES (
121- class IdxT1 , class IdxT2 ,
122- /* requires */ (index_pair_like<std::tuple<IdxT1, IdxT2>, size_t >::value)
123- )
124- constexpr auto first_of (const std::tuple<IdxT1, IdxT2>& i) {
125- return get<0 >(i);
126- }
127-
128- MDSPAN_TEMPLATE_REQUIRES (
129- class IdxT1 , class IdxT2 ,
130- /* requires */ (index_pair_like<std::pair<IdxT1, IdxT2>, size_t >::value)
131- )
132- MDSPAN_INLINE_FUNCTION
133- constexpr auto first_of (const std::pair<IdxT1, IdxT2>& i) {
134- return i.first ;
135- }
136-
137- template <class T >
138- MDSPAN_INLINE_FUNCTION
139- constexpr auto first_of (const std::complex <T> &i) {
140- return i.real ();
141- }
142-
14380template <class OffsetType , class ExtentType , class StrideType >
14481MDSPAN_INLINE_FUNCTION
14582constexpr OffsetType
@@ -161,39 +98,6 @@ constexpr Integral
16198 return i;
16299}
163100
164- MDSPAN_TEMPLATE_REQUIRES (
165- size_t k, class Extents , class Slice ,
166- /* requires */ (index_pair_like<Slice, size_t >::value)
167- )
168- MDSPAN_INLINE_FUNCTION
169- constexpr auto last_of (std::integral_constant<size_t , k>, const Extents &,
170- const Slice &i) {
171- return get<1 >(i);
172- }
173-
174- MDSPAN_TEMPLATE_REQUIRES (
175- size_t k, class Extents , class IdxT1 , class IdxT2 ,
176- /* requires */ (index_pair_like<std::tuple<IdxT1, IdxT2>, size_t >::value)
177- )
178- constexpr auto last_of (std::integral_constant<size_t , k>, const Extents &, const std::tuple<IdxT1, IdxT2>& i) {
179- return get<1 >(i);
180- }
181-
182- MDSPAN_TEMPLATE_REQUIRES (
183- size_t k, class Extents , class IdxT1 , class IdxT2 ,
184- /* requires */ (index_pair_like<std::pair<IdxT1, IdxT2>, size_t >::value)
185- )
186- MDSPAN_INLINE_FUNCTION
187- constexpr auto last_of (std::integral_constant<size_t , k>, const Extents &, const std::pair<IdxT1, IdxT2>& i) {
188- return i.second ;
189- }
190-
191- template <size_t k, class Extents , class T >
192- MDSPAN_INLINE_FUNCTION
193- constexpr auto last_of (std::integral_constant<size_t , k>, const Extents &, const std::complex <T> &i) {
194- return i.imag ();
195- }
196-
197101// Suppress spurious warning with NVCC about no return statement.
198102// This is a known issue in NVCC and NVC++
199103// Depending on the CUDA and GCC version we need both the builtin
@@ -220,7 +124,7 @@ constexpr auto last_of(std::integral_constant<size_t, k>, const Extents &ext,
220124 if constexpr (Extents::static_extent (k) == dynamic_extent) {
221125 return ext.extent (k);
222126 } else {
223- return integral_constant< size_t , Extents::static_extent (k)>();
127+ return constant_wrapper< Extents::static_extent (k), size_t >();
224128 }
225129#if defined(__NVCC__) && !defined(__CUDA_ARCH__) && defined(__GNUC__)
226130 // Even with CUDA_ARCH protection this thing warns about calling host function
0 commit comments