This is the second version of: https://gcc.gnu.org/pipermail/libstdc++/2025-April/060914.html
Following the comments from Jonathan, I reorganized the tests. Using the very effective tricks pointed out by Tomasz, led to a much more concise implementation of `_ExtentsStorage`. If desired, this could be taken further and the helper `_ExtentsStorage` could be completely merged into `extents`. Changes since v1: * All `_neg` tests are replaced by `static_assert`s. Additionally, some other small tests are merged into related files. * Assigning the elements of `_M_dynamic_extents` in a for loop, eliminates the need for `index_sequence`. * The `consteval` trick enables removing all template meta-programming helpers needed to create `_S_dynamic_index{,_inv}`. * The trick to use `initializer_list` removes the need for the ctor `_ExtentsStorage(Integrals...)`. * Introduces a concept for checking if `_OIndexType` is suitable, i.e. convertible & nothrow constructible; and replaces `typename` with the concept. * The internal namespace for details is renamed to `__mdspan`. * Regenerates `include/bits/version.h` to respect `no_stdname`. * Fixes the bug in `extents::size_type`. * Changes the integer conversion `_M_int_cast` as suggested. * Fixed `#include <mdspan>` in `precompiled/stdc++.h`. * Replaced the `array<IndexType, N>` used for storing the dynamic extents with to a custom type `__mdspan::__array`. See Point 2 below. I'd like to point out the following: 1. When calling the ctor `extents<int, 1, 2>(IntLike{}, IntLike{})` the user-defined conversion operator of `IntLike` will be called twice when creating the `initializer_list`, even though ultimately we don't need either of the two values, because both extents are static. 2. In v1 the implementation used `array<Int, 0>` to store the dynamic extents when there are none. Therefore, `[[no_unique_address]]` had no effect. In v2, I've replaced the `array<Int, N>` with a custom type that works with `[[no_unique_address]]`. The patches where tested with `make check-target-libstdc++-v3`. Thank you Tomasz Kaminski and Jonathan Wakely for your helpful review! Luc Grosheintz (4): libstdc++: Setup internal FTM for mdspan. libstdc++: Add header mdspan to the build-system. libstdc++: Implement std::extents [PR107761]. libstdc++: Add tests for std::extents. libstdc++-v3/doc/doxygen/user.cfg.in | 1 + libstdc++-v3/include/Makefile.am | 1 + libstdc++-v3/include/Makefile.in | 1 + libstdc++-v3/include/bits/version.def | 9 + libstdc++-v3/include/bits/version.h | 9 + libstdc++-v3/include/precompiled/stdc++.h | 1 + libstdc++-v3/include/std/mdspan | 352 ++++++++++++++++++ libstdc++-v3/src/c++23/std.cc.in | 6 +- .../23_containers/mdspan/extents/assign.cc | 29 ++ .../mdspan/extents/class_properties.cc | 62 +++ .../23_containers/mdspan/extents/ctor_copy.cc | 75 ++++ .../mdspan/extents/ctor_copy_constexpr.cc | 20 + .../23_containers/mdspan/extents/ctor_ints.cc | 58 +++ .../mdspan/extents/ctor_ints_constexpr.cc | 12 + .../mdspan/extents/ctor_shape_all_extents.cc | 61 +++ .../mdspan/extents/ctor_shape_constexpr.cc | 23 ++ .../extents/ctor_shape_dynamic_extents.cc | 91 +++++ .../mdspan/extents/custom_integer.cc | 87 +++++ .../mdspan/extents/deduction_guide.cc | 34 ++ .../23_containers/mdspan/extents/dextents.cc | 11 + .../23_containers/mdspan/extents/extent.cc | 24 ++ .../23_containers/mdspan/extents/ops_eq.cc | 58 +++ 22 files changed, 1024 insertions(+), 1 deletion(-) create mode 100644 libstdc++-v3/include/std/mdspan create mode 100644 libstdc++-v3/testsuite/23_containers/mdspan/extents/assign.cc create mode 100644 libstdc++-v3/testsuite/23_containers/mdspan/extents/class_properties.cc create mode 100644 libstdc++-v3/testsuite/23_containers/mdspan/extents/ctor_copy.cc create mode 100644 libstdc++-v3/testsuite/23_containers/mdspan/extents/ctor_copy_constexpr.cc create mode 100644 libstdc++-v3/testsuite/23_containers/mdspan/extents/ctor_ints.cc create mode 100644 libstdc++-v3/testsuite/23_containers/mdspan/extents/ctor_ints_constexpr.cc create mode 100644 libstdc++-v3/testsuite/23_containers/mdspan/extents/ctor_shape_all_extents.cc create mode 100644 libstdc++-v3/testsuite/23_containers/mdspan/extents/ctor_shape_constexpr.cc create mode 100644 libstdc++-v3/testsuite/23_containers/mdspan/extents/ctor_shape_dynamic_extents.cc create mode 100644 libstdc++-v3/testsuite/23_containers/mdspan/extents/custom_integer.cc create mode 100644 libstdc++-v3/testsuite/23_containers/mdspan/extents/deduction_guide.cc create mode 100644 libstdc++-v3/testsuite/23_containers/mdspan/extents/dextents.cc create mode 100644 libstdc++-v3/testsuite/23_containers/mdspan/extents/extent.cc create mode 100644 libstdc++-v3/testsuite/23_containers/mdspan/extents/ops_eq.cc -- 2.48.1