]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
libstdc++: Rename std::submdspan_extents and std::submdspan_canonicalize_slices
authorTomasz Kamiński <tkaminsk@redhat.com>
Mon, 16 Feb 2026 12:12:05 +0000 (13:12 +0100)
committerTomasz Kamiński <tkaminsk@redhat.com>
Mon, 16 Feb 2026 14:24:22 +0000 (15:24 +0100)
This patch implements LWG 4491, addressing C++26 NB comments.

libstdc++-v3/ChangeLog:

* include/std/mdspan (std::submdspan_extents): Rename to...
(std::subextents): Renamed from submdspan_extents.
(std::submdspan_canonicalize_slices): Rename to...
(std::canonical_slices): Renamed from submdspan_canonicalize_slices.
* testsuite/23_containers/mdspan/submdspan/submdspan_canonicalize_slices.cc:
Move to...
* testsuite/23_containers/mdspan/submdspan/canonical_slices.cc: ...here.
Updated calls to submdspan_canonicalize_slices.
* testsuite/23_containers/mdspan/submdspan/submdspan_canonicalize_slices_neg.cc:
Move to...
* testsuite/23_containers/mdspan/submdspan/canonical_slices_neg.cc: ...here.
Updated calls to submdspan_canonicalize_slices.
* testsuite/23_containers/mdspan/submdspan/submdspan_extents.cc: Move to...
* testsuite/23_containers/mdspan/submdspan/subextents.cc: ...here.
Qualified and renamed calls to submdspan_extents.
* testsuite/23_containers/mdspan/submdspan/submdspan_extents_neg.cc: Move to...
* testsuite/23_containers/mdspan/submdspan/subextents_neg.cc: ...here.
Qualified and renamed calls to submdspan_extents.

Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
Signed-off-by: Tomasz Kamiński <tkaminsk@redhat.com>
libstdc++-v3/include/std/mdspan
libstdc++-v3/testsuite/23_containers/mdspan/submdspan/canonical_slices.cc [moved from libstdc++-v3/testsuite/23_containers/mdspan/submdspan/submdspan_canonicalize_slices.cc with 87% similarity]
libstdc++-v3/testsuite/23_containers/mdspan/submdspan/canonical_slices_neg.cc [moved from libstdc++-v3/testsuite/23_containers/mdspan/submdspan/submdspan_canonicalize_slices_neg.cc with 95% similarity]
libstdc++-v3/testsuite/23_containers/mdspan/submdspan/subextents.cc [moved from libstdc++-v3/testsuite/23_containers/mdspan/submdspan/submdspan_extents.cc with 88% similarity]
libstdc++-v3/testsuite/23_containers/mdspan/submdspan/subextents_neg.cc [moved from libstdc++-v3/testsuite/23_containers/mdspan/submdspan/submdspan_extents_neg.cc with 85% similarity]

index cedf597d3c2693b78b59c29adcf6fc0071906384..0c89f8e71553c5e5834a72c7c2137dbfff9d3d60 100644 (file)
@@ -3348,8 +3348,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   template<typename _IndexType, size_t... _Extents, typename... _RawSlices>
     requires (sizeof...(_RawSlices) == sizeof...(_Extents))
     constexpr auto
-    submdspan_extents(const extents<_IndexType, _Extents...>& __exts,
-                     _RawSlices... __raw_slices)
+    subextents(const extents<_IndexType, _Extents...>& __exts,
+              _RawSlices... __raw_slices)
     {
       auto __impl = [&__exts](auto... __slices)
       {
@@ -3362,8 +3362,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   template<typename _IndexType, size_t... _Extents, typename... _RawSlices>
     requires (sizeof...(_Extents) == sizeof...(_RawSlices))
     constexpr auto
-    submdspan_canonicalize_slices(const extents<_IndexType, _Extents...>& __exts,
-                                 _RawSlices... __raw_slices)
+    canonical_slices(const extents<_IndexType, _Extents...>& __exts,
+                    _RawSlices... __raw_slices)
     {
       auto __impl = [&__exts](auto... __slices)
       {
similarity index 87%
rename from libstdc++-v3/testsuite/23_containers/mdspan/submdspan/submdspan_canonicalize_slices.cc
rename to libstdc++-v3/testsuite/23_containers/mdspan/submdspan/canonical_slices.cc
index 077bafc2a9b0cb80df5dbb059b48b8eed029681d..5ca123eee5069fd68c093b7577a433c10dd1f994 100644 (file)
@@ -13,11 +13,11 @@ template<typename Extents, typename CInt>
   {
     using IndexType = typename Extents::index_type;
     auto ci_expected = std::cw<IndexType{ci_raw.value}>;
-    auto [ci] = std::submdspan_canonicalize_slices(exts, ci_raw);
+    auto [ci] = std::canonical_slices(exts, ci_raw);
     static_assert(std::same_as<decltype(ci), decltype(ci_expected)>);
     VERIFY(std::cmp_equal(ci.value, ci_raw.value));
 
-    auto [i] = std::submdspan_canonicalize_slices(exts, ci_raw.value);
+    auto [i] = std::canonical_slices(exts, ci_raw.value);
     static_assert(std::same_as<decltype(i), IndexType>);
     VERIFY(std::cmp_equal(i, ci_raw.value));
     return true;
@@ -62,25 +62,25 @@ template<template<typename, typename> typename Pair>
     auto c1 = std::cw<IndexType{1}>;
 
     auto raw_cc = Pair{cbegin, cend};
-    auto [cc] = std::submdspan_canonicalize_slices(exts, raw_cc);
+    auto [cc] = std::canonical_slices(exts, raw_cc);
     assert_same(cc.offset, coffset);
     assert_same(cc.extent, cextent);
     assert_same(cc.stride, c1);
 
     auto raw_cd = Pair{cbegin, cend.value};
-    auto [cd] = std::submdspan_canonicalize_slices(exts, raw_cd);
+    auto [cd] = std::canonical_slices(exts, raw_cd);
     assert_same(cd.offset, coffset);
     assert_same(cd.extent, cextent.value);
     assert_same(cd.stride, c1);
 
     auto raw_dc = Pair{cbegin.value, cend};
-    auto [dc] = std::submdspan_canonicalize_slices(exts, raw_dc);
+    auto [dc] = std::canonical_slices(exts, raw_dc);
     assert_same(dc.offset, coffset.value);
     assert_same(dc.extent, cextent.value);
     assert_same(dc.stride, c1);
 
     auto raw_dd = Pair{cbegin.value, cend.value};
-    auto [dd] = std::submdspan_canonicalize_slices(exts, raw_dd);
+    auto [dd] = std::canonical_slices(exts, raw_dd);
     assert_same(dd.offset, coffset.value);
     assert_same(dd.extent, cextent.value);
     assert_same(dd.stride, c1);
@@ -128,25 +128,25 @@ test_strided_slice(auto exts, auto co, auto ce, auto cs)
   auto cstride = std::cw<IndexType{cs.value}>;
 
   auto raw_ccc = std::strided_slice{co, ce, cs};
-  auto [ccc] = std::submdspan_canonicalize_slices(exts, raw_ccc);
+  auto [ccc] = std::canonical_slices(exts, raw_ccc);
   assert_same(ccc.offset, coffset);
   assert_same(ccc.extent, cextent);
   assert_same(ccc.stride, cstride);
 
   auto raw_dcc = std::strided_slice{co.value, ce, cs};
-  auto [dcc] = std::submdspan_canonicalize_slices(exts, raw_dcc);
+  auto [dcc] = std::canonical_slices(exts, raw_dcc);
   assert_same(dcc.offset, coffset.value);
   assert_same(dcc.extent, cextent);
   assert_same(dcc.stride, cstride);
 
   auto raw_cdc = std::strided_slice{co, ce.value, cs};
-  auto [cdc] = std::submdspan_canonicalize_slices(exts, raw_cdc);
+  auto [cdc] = std::canonical_slices(exts, raw_cdc);
   assert_same(cdc.offset, coffset);
   assert_same(cdc.extent, cextent.value);
   assert_same(cdc.stride, cstride);
 
   auto raw_ccd = std::strided_slice{co, ce, cs.value};
-  auto [ccd] = std::submdspan_canonicalize_slices(exts, raw_ccd);
+  auto [ccd] = std::canonical_slices(exts, raw_ccd);
   assert_same(ccd.offset, coffset);
   assert_same(ccd.extent, cextent);
   assert_same(ccd.stride, cstride.value);
@@ -174,11 +174,11 @@ test_strided_slice_zero_extent(auto exts, auto cs)
   using IndexType = typename decltype(exts)::index_type;
   auto c0 = std::cw<uint8_t{0}>;
   auto raw_ccc = std::strided_slice{c0, c0, cs};
-  auto [ccc] = std::submdspan_canonicalize_slices(exts, raw_ccc);
+  auto [ccc] = std::canonical_slices(exts, raw_ccc);
   assert_same(ccc.stride, std::cw<IndexType{1}>);
 
   auto raw_ccd = std::strided_slice{c0, c0, cs.value};
-  auto [ccd] = std::submdspan_canonicalize_slices(exts, raw_ccd);
+  auto [ccd] = std::canonical_slices(exts, raw_ccd);
   assert_same(ccd.stride, std::cw<IndexType{1}>);
   return true;
 }
similarity index 95%
rename from libstdc++-v3/testsuite/23_containers/mdspan/submdspan/submdspan_canonicalize_slices_neg.cc
rename to libstdc++-v3/testsuite/23_containers/mdspan/submdspan/canonical_slices_neg.cc
index 94bca183aa3b090bfc09f28fec2b877082139d21..6dbfd5e8a1b87e2093a3c6a353a02fb7e10aac6f 100644 (file)
@@ -17,7 +17,7 @@ constexpr bool
 test_rank_mismatch()
 {
   auto exts = std::extents(1);
-  std::submdspan_canonicalize_slices(exts, 0, 0); // { dg-error "no matching" }
+  std::canonical_slices(exts, 0, 0); // { dg-error "no matching" }
   return true;
 }
 
@@ -25,7 +25,7 @@ template<typename Int, typename Extents>
 constexpr bool
 test_under1(Int i1, Extents exts)
 {
-  auto [s1] = std::submdspan_canonicalize_slices(exts, i1);
+  auto [s1] = std::canonical_slices(exts, i1);
   return true;
 }
 
@@ -43,7 +43,7 @@ template<typename Int, typename Extents>
 constexpr bool
 test_over1(Int i1, Extents exts)
 {
-  auto [s1] = std::submdspan_canonicalize_slices(exts, i1);
+  auto [s1] = std::canonical_slices(exts, i1);
   return true;
 }
 
@@ -65,7 +65,7 @@ template<typename Offset, typename Extent, typename Stride, typename Extents>
   constexpr bool
   test_under2(Offset o, Extent e, Stride s, Extents exts)
   {
-    std::submdspan_canonicalize_slices(exts, std::strided_slice{o, e, s});
+    std::canonical_slices(exts, std::strided_slice{o, e, s});
     return true;
   }
 
@@ -105,7 +105,7 @@ template<typename Offset, typename Extent, typename Stride, typename Extents>
   constexpr bool
   test_over2(Offset o, Extent e, Stride s, Extents exts)
   {
-    std::submdspan_canonicalize_slices(exts, std::strided_slice{o, e, s});
+    std::canonical_slices(exts, std::strided_slice{o, e, s});
     return true;
   }
 
@@ -157,7 +157,7 @@ test_overflow1(auto o, auto e)
 {
   auto exts = std::extents<uint8_t, dyn>{255};
   auto slice = std::strided_slice{o, e, 1};
-  std::submdspan_canonicalize_slices(exts, slice);
+  std::canonical_slices(exts, slice);
   return true;
 }
 
@@ -171,7 +171,7 @@ test_overflow2(auto b, auto e)
 {
   auto exts = std::extents<uint8_t, dyn>{255};
   auto slice = std::pair{b, e};
-  std::submdspan_canonicalize_slices(exts, slice);
+  std::canonical_slices(exts, slice);
   return true;
 }
 
@@ -192,7 +192,7 @@ test_invalid(auto e, auto s)
 {
   auto exts = std::extents(5);
   auto slice = std::strided_slice(0, e, s);
-  std::submdspan_canonicalize_slices(exts, slice);
+  std::canonical_slices(exts, slice);
   return true;
 }
 
similarity index 88%
rename from libstdc++-v3/testsuite/23_containers/mdspan/submdspan/submdspan_extents.cc
rename to libstdc++-v3/testsuite/23_containers/mdspan/submdspan/subextents.cc
index 841910a77c8c5617ae3cf0354804ddad29aad955..ae77d3d96a89772a3c0e04798a5e92728492a6a7 100644 (file)
@@ -11,7 +11,7 @@ constexpr bool
 test_from_full_extent()
 {
   auto exts = std::extents<int, 3, dyn, 7>{};
-  auto sub_exts = submdspan_extents(exts, 1, all, all);
+  auto sub_exts = std::subextents(exts, 1, all, all);
   VERIFY(sub_exts.rank() == 2);
   VERIFY(sub_exts.static_extent(0) == dyn);
   VERIFY(sub_exts.extent(0) == exts.extent(1));
@@ -27,7 +27,7 @@ template<template<typename, typename> typename Pair, template<int> typename Cw>
     auto s0 = Cw<1>{};
     auto s1 = Pair{Cw<1>{}, Cw<2>{}};
     auto s2 = Pair{Cw<1>{}, 4};
-    auto sub_exts = submdspan_extents(exts, s0, s1, s2);
+    auto sub_exts = std::subextents(exts, s0, s1, s2);
     VERIFY(sub_exts.rank() == 2);
     VERIFY(sub_exts.static_extent(0) == size_t(get<1>(s1) - get<0>(s1)));
     VERIFY(sub_exts.static_extent(1) == dyn);
@@ -50,7 +50,7 @@ template<typename Int>
   test_from_int_like_as_scalar()
   {
     auto exts = std::extents<int, 3, 5>{};
-    auto sub_exts = submdspan_extents(exts, Int(1), std::tuple{1, 3});
+    auto sub_exts = std::subextents(exts, Int(1), std::tuple{1, 3});
     VERIFY(sub_exts.rank() == 1);
     VERIFY(sub_exts.static_extent(0) == dyn);
     VERIFY(sub_exts.extent(0) == 2);
@@ -61,7 +61,7 @@ template<template<int> typename Cw>
   test_from_const_int()
   {
     auto exts = std::extents<int, 3, 5>{};
-    auto sub_exts = submdspan_extents(exts, Cw<1>{}, std::tuple{1, 3});
+    auto sub_exts = std::subextents(exts, Cw<1>{}, std::tuple{1, 3});
     VERIFY(sub_exts.rank() == 1);
     VERIFY(sub_exts.static_extent(0) == dyn);
     VERIFY(sub_exts.extent(0) == 2);
@@ -73,7 +73,7 @@ template<typename Int>
   test_from_int_like_in_tuple()
   {
     auto exts = std::extents<int, 3, 5>{};
-    auto sub_exts = submdspan_extents(exts, Int(1), std::tuple{Int(1), Int(3)});
+    auto sub_exts = std::subextents(exts, Int(1), std::tuple{Int(1), Int(3)});
     VERIFY(sub_exts.rank() == 1);
     VERIFY(sub_exts.static_extent(0) == dyn);
     VERIFY(sub_exts.extent(0) == 2);
@@ -89,7 +89,7 @@ template<template<int> typename Cw>
       auto s0 = 1;
       auto s1 = std::strided_slice{0, 0, 0};
       auto s2 = std::strided_slice{1, Cw<0>{}, 0};
-      auto sub_exts = submdspan_extents(exts, s0, s1, s2);
+      auto sub_exts = std::subextents(exts, s0, s1, s2);
       VERIFY(sub_exts.rank() == 2);
       VERIFY(sub_exts.static_extent(0) == dyn);
       VERIFY(sub_exts.extent(0) == 0);
@@ -100,7 +100,7 @@ template<template<int> typename Cw>
       auto s0 = 1;
       auto s1 = std::strided_slice{0, 2, Cw<1>{}};
       auto s2 = std::strided_slice{1, Cw<2>{}, 1};
-      auto sub_exts = submdspan_extents(exts, s0, s1, s2);
+      auto sub_exts = std::subextents(exts, s0, s1, s2);
       VERIFY(sub_exts.rank() == 2);
       VERIFY(sub_exts.static_extent(0) == dyn);
       VERIFY(sub_exts.extent(0) == 2);
@@ -113,7 +113,7 @@ template<template<int> typename Cw>
       auto s0 = 1;
       auto s1 = std::strided_slice{1, Cw<4>{}, 2};
       auto s2 = std::strided_slice{1, Cw<10>{}, Cw<3>{}};
-      auto sub_exts = submdspan_extents(exts, s0, s1, s2);
+      auto sub_exts = std::subextents(exts, s0, s1, s2);
       VERIFY(sub_exts.rank() == 2);
       VERIFY(sub_exts.static_extent(0) == dyn);
       VERIFY(sub_exts.extent(0) == 2);
@@ -125,7 +125,7 @@ template<template<int> typename Cw>
       auto s0 = std::strided_slice(0, 3, 2);
       auto s1 = std::strided_slice(1, 4, 2);
       auto s2 = std::strided_slice(0, 7, 3);
-      auto sub_exts = submdspan_extents(exts, s0, s1, s2);
+      auto sub_exts = std::subextents(exts, s0, s1, s2);
       VERIFY(sub_exts.rank() == 3);
       VERIFY(sub_exts.extent(0) == 2);
       VERIFY(sub_exts.extent(1) == 2);
similarity index 85%
rename from libstdc++-v3/testsuite/23_containers/mdspan/submdspan/submdspan_extents_neg.cc
rename to libstdc++-v3/testsuite/23_containers/mdspan/submdspan/subextents_neg.cc
index cf27c0c7e4d6d19e4d786a2ccdfebcc68cf663d4..c81a1383e3cba73115613b541bbd44f1905ed5d0 100644 (file)
@@ -10,7 +10,7 @@ constexpr bool
 test_unrelated_stride_type()
 {
   auto exts = std::extents(3, 5, 7);
-  auto sub_exts = submdspan_extents(exts, 1, NotASlice{}, 2);  // { dg-error "required from" }
+  auto sub_exts = subextents(exts, 1, NotASlice{}, 2);  // { dg-error "required from" }
   return true;
 }
 static_assert(test_unrelated_stride_type());
@@ -20,7 +20,7 @@ test_invalid_stride_zero()
 {
   auto exts = std::extents(3, 5, 7);
   auto s = std::strided_slice{0, 1, 0};
-  auto sub_exts = submdspan_extents(exts, 1, s, 2);  // { dg-error "expansion of" }
+  auto sub_exts = std::subextents(exts, 1, s, 2);  // { dg-error "expansion of" }
   return true;
 }
 static_assert(test_invalid_stride_zero());
@@ -30,7 +30,7 @@ constexpr bool
 test_out_of_bounds(const Slice& slice)
 {
   auto exts = std::extents<uint16_t, 3, 5, 7>{};
-  auto sub_exts = submdspan_extents(exts, 1, slice, 2);  // { dg-error "expansion of" }
+  auto sub_exts = std::subextents(exts, 1, slice, 2);  // { dg-error "expansion of" }
   return true;
 }
 static_assert(test_out_of_bounds(std::strided_slice{0, 6, 1}));  // { dg-error "expansion of" }