On Tue, 9 Dec 2025 at 09:37, Tomasz Kamiński <[email protected]> wrote: > > From: Luc Grosheintz <[email protected]> > > Implements `submdspan` and `submdspan_mapping` for layout_left as > described in P3663 (Future proofing mdspan). > > When computing the offset of the submdspan, one must check that the > lower bound of the slice range isn't out-of-range. There's a few > cases when the lower bound is never out-of-range: > > - full_extent and exts.extent(k) != 0, > - collapsing slice types. > > If those conditions are known to hold, no checks are generated. > > Similarly, if all slices are full_extent, there's no need to call > mapping(0,...,0) for standardized mappings. > > The implementation prepares to use the symmetry between layout_left and > layout_right and introduces concepts like a "layout side", i.e. left, > right or unknown/strided. > > The tests use an iterator to replace nested for-loops. Which also makes > it easier to write the core test logic in a rank-independent manner. > > PR libstdc++/110352 > > libstdc++-v3/ChangeLog: > > * include/std/mdspan (__mdspan::__is_submdspan_mapping_result) > (__mdspan::__submdspan_mapping_result, __mdspan::__fwd_prod) > (__mdspan::__acceptable_slice_type, __mdspan::__slice_begin) > (__mdspan::__suboffset, __mdspan::_LayoutSide, > __mdspan::__mapping_side) > (__mdspan::_StridesTrait, __mdspan::__substrides_generic) > (__mdspan::__substrides_standardized, __mdspan::__substrides) > (__mdspan::__is_unit_stride_slice, __mdspan::_SliceKind) > (__mdspan::__make_slice_kind, __mdspan::__make_slice_kind_array) > (__mdspan::__is_block, __mdspan::__padded_block_begin_generic) > (__mdspan::__padded_block_begin, __mpdspan::_SubMdspanMapping) > (__mdspan::__submdspan_mapping_impl): Define. > (__mdspan::__dynamic_slice_extent, __mdspan::__static_slice_extent) > (__mdspan::__subextents): Move eariel in the file.
"earlier" > (layout_left::mapping::submdspan_mapping, > __mdspan::__sliceable_mapping) > (__mdspan::__submapping, submdspan): Define. > * src/c++23/std.cc.in: Add submdspan. > * testsuite/23_containers/mdspan/submdspan/generic.cc: New test. > * testsuite/23_containers/mdspan/submdspan/selections/left.cc: > Instantiate selection tests for layout_left. > * testsuite/23_containers/mdspan/submdspan/selections/testcases.h: > Generic > tests different selections. > * testsuite/23_containers/mdspan/submdspan/submdspan_mapping.cc: New > test. > * testsuite/23_containers/mdspan/submdspan/submdspan_neg.cc: New test. > > Reviewed-by: Tomasz Kamiński <[email protected]> > Signed-off-by: Luc Grosheintz <[email protected]> > --- > v7: > - list all new entries in changes. > - move submdspan_mapping poison pill before concept, > - use const mapping as argument to concept > - refactor __submdspan into __submapping funciton. > > Tested *mdspan* locally. We've reached the point where I no longer understand the <mdspan> code! But this looks OK for trunk, with the typo above fixed.
