gnu/gcc/e920613db52adece7e3de5f2a2812247c72782f6 libstdc++: Change meaning of strided_slice::extent per P3982R2
This patch implements the changes suggested in P3982R2 (and PL007 NB comment)
for C++26, but changing the strided_slice::extent to indicate number of
elements (extent) in the produced (output) mdspan, instead of input.
libstdc++-v3/ChangeLog:
* include/std/mdspan (__mdspan::__static_slice_extent)
(__mdspan::__dynamic_slice_extent): Return unmodified extent
value for strided_slice.
(__mdspan::__substrides_generic, __mdspan::__substrides_standardized):
Multipliy stride, if more than one element is requested.
(__mdspan::__canonical_range_slice): Define.
(__mdspan::__slice_cast): Use __canonical_range_slice for range_slice
and two elements tuples.
(__mdspan::__check_inrange_index): Define.
(__mdspan::__check_valid_slice): Validate if slice.offset +
(slice.extent - 1) * slice.stride fits into extent of given
dimension. Check stride if slice.extent > 1.
* testsuite/23_containers/mdspan/submdspan/canonical_slices.cc:
Add test for range_slice.
* testsuite/23_containers/mdspan/submdspan/canonical_slices_neg.cc:
Add tests validating new conditions.
* testsuite/23_containers/mdspan/submdspan/selections/testcases.h:
Adjusted for change of meaing of strided_slice::extent.
* testsuite/23_containers/mdspan/submdspan/subextents.cc:
Adjusted for change of meaing of strided_slice::extent. And expanded
range_slice tests.
* testsuite/23_containers/mdspan/submdspan/subextents_neg.cc:
Adjusted for change of meaing of strided_slice::extent.
* testsuite/23_containers/mdspan/submdspan/submdspan_neg.cc:
Adjust test for stride value.
Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
Signed-off-by: Tomasz Kamiński <tkaminsk@redhat.com>
7 files changed