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