libstdc++: Handling user-defined interlike object in submdspan.
Luc Grosheintz
luc.grosheintz@gmail.com
Tue Sep 30 09:05:04 GMT 2025
On 9/30/25 10:01 AM, Tomasz Kaminski wrote:
>>
>> I canonicalize tuple-like to `std::tuple`s of possibly wrapped
>> index_type; and not to stride<*, *, std::cw<1>>.
>>
>> The advantage is that the preconditions remain the same, because
>> tuples still exist, it's just that we don't encounter as much
>> variability but the kinds of objects remain the same.
>>
>> Generally, and as written in the paper, it does make sense to maybe
>> not canonicalize things like:
>>
>> - std::array<index_type, 2>
>> - std::tuple<std::constant_wrapper<index_type, *>,
>> std::constant_wrapper<index_type, *>>
>>
> Note that pair-like for the submdspan is representing [begin, end) range,
> while the strided_slice has [begin, offset, stride)?
>
Yes, the thought is that
strided_slice{begin, end - begin, std::cw<1>}
is a less direct way of expressing the idea. So users
might opt for one of the other two instead. If we allow
those to be passed through unchanged, they'll not have to
worry about optimizing their code by making sure they
use stride_slice{..., std::cw<1>}, it would just work.
>
>>
>> because those are very natural ways of specifying that kind of slice.
>> Therefore, even if there's a cost to canonicalization, every kind of
>> slice has a convenient canonical form (that users can provide to skip
>> canonicalization).
>>
> I do not think there should be differences between canonical forms of
> strided_slice and pair_like, they represent the same concept. And
> This should reduce the number of various concepts that we need to handle.
> Note that the __first, __last functions are now completely gone from the
> wording.
I agree that multiple canonical forms is odd. On the other hand
it's mentioned/suggested in the paper that standardized mapping
may do less canonicalization:
https://isocpp.org/files/papers/D3663R3.html#submdspan-can-skip-canonicalization-for-standard-layout-mappings
>
>
>>
>> Is it okay to send this variation as a v1? Naturally, you can then
>> say: nope, do the full P3663 please.
>>
> You can send that of course, but after rewriting the whole wording section,
> I think the previous
> specification was a bit of a dead end, so I think I wil answer that way
> anyway.
>
>
>>>
>>>
>>>>
>>>>>>
>>>>>> The idea I'm pursuing is to follow the pattern of casting slices to
>>>>>> "standard slices" immediately at the user-facing API layer, e.g.
>>>>>>
>>>>>> template<typename _Slices...>
>>>>>> constexpr auto
>>>>>> submdspan_extents(_Slices... __slices)
>>>>>> {
>>>>>> return
>> __submdspan_extents(__slice_cast(std::move(__slices))...);
>>>>>> }
>>>>>>
>>>>
>>>>
>>>
>>
>>
>
More information about the Libstdc++
mailing list