mirror of
https://github.com/gcc-mirror/gcc.git
synced 2026-05-06 14:59:39 +02:00
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>