[PATCH v4 0/6] Implement mdspan.
Tomasz Kaminski
tkaminsk@redhat.com
Mon Jul 14 06:57:49 GMT 2025
Hi Luc,
While running the libc++ test on libstdc++ we have found the following
issue in our implementation.
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=121061
Would you be interested in looking into fixing this?
Also, libc++ makes the default constructor of mdpsan conditionally noexcept
as extension
(standard does not require it
https://eel.is/c++draft/views.multidim#mdspan.mdspan.cons).
We could do the same. Instead of writing a big conditional noexcept
specification, I would suggest
defaultint the constructor on first declaration:
constexpr
mdspan()
requires (rank_dynamic() > 0)
&& is_default_constructible_v<data_handle_type>
&& is_default_constructible_v<mapping_type>
&& is_default_constructible_v<accessor_type>
= default;
And then having default member initializers:
private:
[[no_unique_address]] accessor_type _M_accessor = accessor_type();
[[no_unique_address]] mapping_type _M_mapping = mapping_type();
[[no_unique_address]] data_handle_type _M_handle = data_handle_type();
We do not want to use "{}" as the samantis is a bit differnt.
Regards,
Tomasz
On Tue, Jul 8, 2025 at 3:44 PM Tomasz Kaminski <tkaminsk@redhat.com> wrote:
> All patches were merged. I will double check that we got all the papers
> listed and the issue, and close it.
> Thanks again for your submissions.
>
> On Tue, Jul 8, 2025 at 10:26 AM Luc Grosheintz <luc.grosheintz@gmail.com>
> wrote:
>
>> Patches 1/5 ... 4/5 aren't sent because corresponding commits from v3
>> should be used. The changes for 5/5 are:
>>
>> * Fix ADL issue in swap and create tests.
>> * Replace pragma once with include guard in layout_like.h.
>> * Use VERIFY(md.empty()) when checking value initialization.
>>
>> Since the code for swap is identical for all three members of mdspan,
>> this commit intentionally checks that the accessor is ADL swappable, but
>> not the other two memebers. Doing so allows us to have a single, short
>> class purely dedicated to ADL. Otherwise we'd need to put OpaqueLayout
>> and LayoutLike into a namespace and add ADL related logic. I tried it
>> and wasn't too happy with the result. This felt shorter, more directly
>> to the point while still checking that the implemented swap function
>> allows ADL for swapping all members variables. I tested effectiveness
>> of the test by reverting the fix and making sure the test fails.
>>
>> This version of the patch series also adds the commit to update the
>> FTM. The changes are:
>>
>> * Update the commit message to mention the related ticket.
>> * Rename the file.
>> * Implement a more verbose version of the test.
>>
>> Luc Grosheintz (6):
>> libstdc++: Check prerequisites of layout_*::operator().
>> libstdc++: Check prerequisite of extents::extents.
>> libstdc++: Restructure mdspan tests to reuse IntLike.
>> libstdc++: Implement __mdspan::__size.
>> libstdc++: Implement mdspan and tests [PR107761].
>> libstdc++: Set FMT for complete C++23 mdspan [PR107761].
>>
>> libstdc++-v3/include/bits/version.def | 3 +-
>> libstdc++-v3/include/bits/version.h | 3 +-
>> libstdc++-v3/include/std/mdspan | 315 ++++++++-
>> libstdc++-v3/src/c++23/std.cc.in | 3 +-
>> .../23_containers/mdspan/class_mandate_neg.cc | 41 ++
>> .../mdspan/extents/class_mandates_neg.cc | 2 +
>> .../mdspan/extents/custom_integer.cc | 27 +-
>> .../mdspan/extents/extents_mismatch_neg.cc | 35 +
>> .../23_containers/mdspan/extents/int_like.h | 28 +
>> .../testsuite/23_containers/mdspan/ftm.cc | 9 +
>> .../23_containers/mdspan/layout_like.h | 83 +++
>> .../mdspan/layouts/debug/out_of_bounds_neg.cc | 30 +
>> .../testsuite/23_containers/mdspan/mdspan.cc | 643 ++++++++++++++++++
>> .../23_containers/mdspan/out_of_bounds_neg.cc | 24 +
>> 14 files changed, 1212 insertions(+), 34 deletions(-)
>> create mode 100644
>> libstdc++-v3/testsuite/23_containers/mdspan/class_mandate_neg.cc
>> create mode 100644
>> libstdc++-v3/testsuite/23_containers/mdspan/extents/extents_mismatch_neg.cc
>> create mode 100644
>> libstdc++-v3/testsuite/23_containers/mdspan/extents/int_like.h
>> create mode 100644 libstdc++-v3/testsuite/23_containers/mdspan/ftm.cc
>> create mode 100644
>> libstdc++-v3/testsuite/23_containers/mdspan/layout_like.h
>> create mode 100644
>> libstdc++-v3/testsuite/23_containers/mdspan/layouts/debug/out_of_bounds_neg.cc
>> create mode 100644 libstdc++-v3/testsuite/23_containers/mdspan/mdspan.cc
>> create mode 100644
>> libstdc++-v3/testsuite/23_containers/mdspan/out_of_bounds_neg.cc
>>
>> --
>> 2.49.0
>>
>>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://gcc.gnu.org/pipermail/libstdc++/attachments/20250714/2b5a7a99/attachment-0001.htm>
More information about the Libstdc++
mailing list