diff --git a/include/experimental/__p0009_bits/layout_stride.hpp b/include/experimental/__p0009_bits/layout_stride.hpp index 2dd7ec52..af3380c8 100644 --- a/include/experimental/__p0009_bits/layout_stride.hpp +++ b/include/experimental/__p0009_bits/layout_stride.hpp @@ -121,7 +121,7 @@ struct layout_stride { template _MDSPAN_HOST_DEVICE - constexpr index_type __get_size(extents,integer_sequence<::std::size_t, Idx...>) const { + constexpr index_type __get_size(::std::experimental::extents,integer_sequence<::std::size_t, Idx...>) const { return _MDSPAN_FOLD_TIMES_RIGHT( static_cast(extents().extent(Idx)), 1 ); } diff --git a/include/experimental/__p2630_bits/strided_index_range.hpp b/include/experimental/__p2630_bits/strided_slice.hpp similarity index 63% rename from include/experimental/__p2630_bits/strided_index_range.hpp rename to include/experimental/__p2630_bits/strided_slice.hpp index 01af0b83..f2f51bbc 100644 --- a/include/experimental/__p2630_bits/strided_index_range.hpp +++ b/include/experimental/__p2630_bits/strided_slice.hpp @@ -15,12 +15,21 @@ // //@HEADER +#include + namespace std { namespace experimental { +namespace { + template + struct __mdspan_is_integral_constant: std::false_type {}; + + template + struct __mdspan_is_integral_constant>: std::true_type {}; +} // Slice Specifier allowing for strides and compile time extent template -struct strided_index_range { +struct strided_slice { using offset_type = OffsetType; using extent_type = ExtentType; using stride_type = StrideType; @@ -28,6 +37,10 @@ struct strided_index_range { OffsetType offset; ExtentType extent; StrideType stride; + + static_assert(is_integral_v || __mdspan_is_integral_constant::value); + static_assert(is_integral_v || __mdspan_is_integral_constant::value); + static_assert(is_integral_v || __mdspan_is_integral_constant::value); }; } // experimental diff --git a/include/experimental/__p2630_bits/submdspan_extents.hpp b/include/experimental/__p2630_bits/submdspan_extents.hpp index c293b3fd..6f2c6a2e 100644 --- a/include/experimental/__p2630_bits/submdspan_extents.hpp +++ b/include/experimental/__p2630_bits/submdspan_extents.hpp @@ -14,7 +14,7 @@ // //@HEADER -#include "strided_index_range.hpp" +#include "strided_slice.hpp" namespace std { namespace experimental { namespace detail { @@ -42,12 +42,12 @@ constexpr auto inv_map_rank(integral_constant, index_sequence struct is_strided_index_range : false_type {}; +// Helper for identifying strided_slice +template struct is_strided_slice : false_type {}; template -struct is_strided_index_range< - strided_index_range> : true_type {}; +struct is_strided_slice< + strided_slice> : true_type {}; // first_of(slice): getting begin of slice specifier range MDSPAN_TEMPLATE_REQUIRES( @@ -77,7 +77,7 @@ constexpr auto first_of(const Slice &i) { template MDSPAN_INLINE_FUNCTION constexpr OffsetType -first_of(const strided_index_range &r) { +first_of(const strided_slice &r) { return r.offset; } @@ -155,7 +155,7 @@ template , const Extents &, - const strided_index_range &r) { + const strided_slice &r) { return r.extent; } @@ -169,7 +169,7 @@ constexpr auto stride_of(const T &) { template MDSPAN_INLINE_FUNCTION constexpr auto -stride_of(const strided_index_range &r) { +stride_of(const strided_slice &r) { return r.stride; } @@ -185,7 +185,7 @@ MDSPAN_INLINE_FUNCTION constexpr auto divide(const integral_constant &, const integral_constant &) { // cutting short division by zero - // this is used for strided_index_range with zero extent/stride + // this is used for strided_slice with zero extent/stride return integral_constant(); } @@ -214,7 +214,7 @@ struct StaticExtentFromRange, constexpr static size_t value = val1 - val0; }; -// compute new static extent from strided_index_range, preserving static +// compute new static extent from strided_slice, preserving static // knowledge template struct StaticExtentFromStridedRange { constexpr static size_t value = dynamic_extent; @@ -233,7 +233,7 @@ struct extents_constructor { MDSPAN_TEMPLATE_REQUIRES( class Slice, class... SlicesAndExtents, /* requires */(!is_convertible_v && - !is_strided_index_range::value) + !is_strided_slice::value) ) MDSPAN_INLINE_FUNCTION constexpr static auto next_extent(const Extents &ext, const Slice &sl, @@ -270,7 +270,7 @@ struct extents_constructor { MDSPAN_INLINE_FUNCTION constexpr static auto next_extent(const Extents &ext, - const strided_index_range &r, + const strided_slice &r, SlicesAndExtents... slices_and_extents) { using index_t = typename Extents::index_type; using new_static_extent_t = diff --git a/tests/test_submdspan.cpp b/tests/test_submdspan.cpp index 251b9219..b774449a 100644 --- a/tests/test_submdspan.cpp +++ b/tests/test_submdspan.cpp @@ -147,22 +147,22 @@ using submdspan_test_types = , std::tuple, args_t<6,4,5,6,7,8>, stdex::extents, int, int, int, int, std::pair, stdex::full_extent_t> , std::tuple, args_t<6,4,5,6,7,8>, stdex::extents, int, int, int, int, int, stdex::full_extent_t> // LayoutLeft to LayoutStride - , std::tuple, args_t<10>, stdex::dextents, stdex::strided_index_range> - , std::tuple, args_t<10,20>, stdex::dextents, stdex::strided_index_range, int> + , std::tuple, args_t<10>, stdex::dextents, stdex::strided_slice> + , std::tuple, args_t<10,20>, stdex::dextents, stdex::strided_slice, int> , std::tuple, args_t<10,20>, stdex::dextents, std::pair, stdex::full_extent_t> - , std::tuple, args_t<10,20>, stdex::dextents, std::pair, stdex::strided_index_range> - , std::tuple, args_t<10,20>, stdex::dextents, stdex::strided_index_range, std::pair> - , std::tuple, args_t<10,20>, stdex::dextents, stdex::strided_index_range, stdex::strided_index_range> + , std::tuple, args_t<10,20>, stdex::dextents, std::pair, stdex::strided_slice> + , std::tuple, args_t<10,20>, stdex::dextents, stdex::strided_slice, std::pair> + , std::tuple, args_t<10,20>, stdex::dextents, stdex::strided_slice, stdex::strided_slice> , std::tuple, args_t<6,4,5,6,7,8>, stdex::extents, stdex::full_extent_t, int, std::pair, int, int, stdex::full_extent_t> , std::tuple, args_t<6,4,5,6,7,8>, stdex::extents, int, stdex::full_extent_t, std::pair, int, stdex::full_extent_t, int> // layout_right to layout_stride - , std::tuple, args_t<10>, stdex::dextents, stdex::strided_index_range> - , std::tuple, args_t<10>, stdex::extents, stdex::strided_index_range,std::integral_constant>> - , std::tuple, args_t<10,20>, stdex::dextents, stdex::strided_index_range, int> + , std::tuple, args_t<10>, stdex::dextents, stdex::strided_slice> + , std::tuple, args_t<10>, stdex::extents, stdex::strided_slice,std::integral_constant>> + , std::tuple, args_t<10,20>, stdex::dextents, stdex::strided_slice, int> , std::tuple, args_t<10,20>, stdex::dextents, stdex::full_extent_t, std::pair> - , std::tuple, args_t<10,20>, stdex::dextents, std::pair, stdex::strided_index_range> - , std::tuple, args_t<10,20>, stdex::dextents, stdex::strided_index_range, std::pair> - , std::tuple, args_t<10,20>, stdex::dextents, stdex::strided_index_range, stdex::strided_index_range> + , std::tuple, args_t<10,20>, stdex::dextents, std::pair, stdex::strided_slice> + , std::tuple, args_t<10,20>, stdex::dextents, stdex::strided_slice, std::pair> + , std::tuple, args_t<10,20>, stdex::dextents, stdex::strided_slice, stdex::strided_slice> , std::tuple, args_t<6,4,5,6,7,8>, stdex::extents, stdex::full_extent_t, int, std::pair, int, int, stdex::full_extent_t> , std::tuple, args_t<6,4,5,6,7,8>, stdex::extents, int, stdex::full_extent_t, std::pair, int, stdex::full_extent_t, int> // Testing of customization point design @@ -172,8 +172,8 @@ using submdspan_test_types = , std::tuple, args_t<10,20>, stdex::dextents, stdex::full_extent_t, stdex::full_extent_t> , std::tuple, args_t<10,20>, stdex::dextents, std::pair, stdex::full_extent_t> , std::tuple, args_t<10,20>, stdex::dextents, int, stdex::full_extent_t> - , std::tuple, args_t<10>, stdex::dextents, stdex::strided_index_range> - , std::tuple, args_t<10,20>, stdex::dextents, stdex::strided_index_range, int> + , std::tuple, args_t<10>, stdex::dextents, stdex::strided_slice> + , std::tuple, args_t<10,20>, stdex::dextents, stdex::strided_slice, int> >; template struct TestSubMDSpan; @@ -204,13 +204,13 @@ struct TestSubMDSpan< return std::pair(1,3); } MDSPAN_INLINE_FUNCTION - static auto create_slice_arg(stdex::strided_index_range) { - return stdex::strided_index_range{1,3,2}; + static auto create_slice_arg(stdex::strided_slice) { + return stdex::strided_slice{1,3,2}; } template MDSPAN_INLINE_FUNCTION - static auto create_slice_arg(stdex::strided_index_range, std::integral_constant>) { - return stdex::strided_index_range, std::integral_constant>{1,std::integral_constant(), std::integral_constant()}; + static auto create_slice_arg(stdex::strided_slice, std::integral_constant>) { + return stdex::strided_slice, std::integral_constant>{1,std::integral_constant(), std::integral_constant()}; } MDSPAN_INLINE_FUNCTION static auto create_slice_arg(stdex::full_extent_t) { @@ -231,14 +231,14 @@ struct TestSubMDSpan< template MDSPAN_INLINE_FUNCTION static bool match_expected_extents(int src_idx, int sub_idx, SrcExtents src_ext, SubExtents sub_ext, - stdex::strided_index_range p, SliceArgs ... slices) { + stdex::strided_slice p, SliceArgs ... slices) { using idx_t = typename SubExtents::index_type; return (sub_ext.extent(sub_idx)==static_cast((p.extent+p.stride-1)/p.stride)) && match_expected_extents(++src_idx, ++sub_idx, src_ext, sub_ext, slices...); } template MDSPAN_INLINE_FUNCTION static bool match_expected_extents(int src_idx, int sub_idx, SrcExtents src_ext, SubExtents sub_ext, - stdex::strided_index_range,std::integral_constant>, SliceArgs ... slices) { + stdex::strided_slice,std::integral_constant>, SliceArgs ... slices) { return (sub_ext.extent(sub_idx)==0) && match_expected_extents(++src_idx, ++sub_idx, src_ext, sub_ext, slices...); } template