From 90f7bbfe2219770ac8b25d0f99320ed3a4fd7736 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Tomasz=20Kami=C5=84ski?= Date: Thu, 5 Jun 2025 10:40:10 +0200 Subject: [PATCH] libstdc++: Uglify __mapping_alike template parameter and fix test and typo in comment. MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit When the static assert was generated from instantiations of default member initializer of class B, the error was not generated for B<1, std::layout_left, std::layout_left> case, only when -D_GLIBCXX_DEBUG was set. Changing B calls to functions fixes that. We also replace class with typename in template head of layout_right::mapping constructors. libstdc++-v3/ChangeLog: * include/std/mdspan (__mdspan::__mapping_alike): Rename template parameter from M to _M_p. (layout_right::mapping): Replace class with typename in template head. (layout_stride::mapping): Fix typo in comment. * testsuite/23_containers/mdspan/layouts/class_mandate_neg.cc: Changed B to function. Reviewed-by: Jonathan Wakely Signed-off-by: Tomasz Kamiński --- libstdc++-v3/include/std/mdspan | 22 +++++++++---------- .../mdspan/layouts/class_mandate_neg.cc | 18 ++++++++------- 2 files changed, 21 insertions(+), 19 deletions(-) diff --git a/libstdc++-v3/include/std/mdspan b/libstdc++-v3/include/std/mdspan index 4a3e863bed5..6dc2441f80b 100644 --- a/libstdc++-v3/include/std/mdspan +++ b/libstdc++-v3/include/std/mdspan @@ -691,7 +691,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION : mapping(__other.extents(), __mdspan::__internal_ctor{}) { } - template + template requires (extents_type::rank() <= 1) && is_constructible_v constexpr explicit(!is_convertible_v<_OExtents, extents_type>) @@ -699,7 +699,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION : mapping(__other.extents(), __mdspan::__internal_ctor{}) { } - template + template requires is_constructible_v constexpr explicit(extents_type::rank() > 0) mapping(const layout_stride::mapping<_OExtents>& __other) noexcept @@ -780,16 +780,16 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION namespace __mdspan { - template + template concept __mapping_alike = requires { - requires __is_extents; - { M::is_always_strided() } -> same_as; - { M::is_always_exhaustive() } -> same_as; - { M::is_always_unique() } -> same_as; - bool_constant::value; - bool_constant::value; - bool_constant::value; + requires __is_extents; + { _Mp::is_always_strided() } -> same_as; + { _Mp::is_always_exhaustive() } -> same_as; + { _Mp::is_always_unique() } -> same_as; + bool_constant<_Mp::is_always_strided()>::value; + bool_constant<_Mp::is_always_exhaustive()>::value; + bool_constant<_Mp::is_always_unique()>::value; }; template @@ -847,7 +847,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION mapping() noexcept { // The precondition is either statically asserted, or automatically - // satisfied because dynamic extents are zero-initialzied. + // satisfied because dynamic extents are zero-initialized. size_t __stride = 1; for (size_t __i = extents_type::rank(); __i > 0; --__i) { diff --git a/libstdc++-v3/testsuite/23_containers/mdspan/layouts/class_mandate_neg.cc b/libstdc++-v3/testsuite/23_containers/mdspan/layouts/class_mandate_neg.cc index 70a25707cb2..7091153daba 100644 --- a/libstdc++-v3/testsuite/23_containers/mdspan/layouts/class_mandate_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/mdspan/layouts/class_mandate_neg.cc @@ -18,7 +18,8 @@ template }; template - struct B + bool + B() { using Extents = std::extents; using OExtents = std::extents; @@ -27,20 +28,21 @@ template using OMapping = typename OLayout::mapping; Mapping m{OMapping{}}; + return true; }; A a_left; // { dg-error "required from" } A a_right; // { dg-error "required from" } A a_stride; // { dg-error "required from" } -B<1, std::layout_left, std::layout_left> b0; // { dg-error "required here" } -B<2, std::layout_left, std::layout_stride> b1; // { dg-error "required here" } +auto b1 = B<1, std::layout_left, std::layout_left>(); // { dg-error "required from" } +auto b2 = B<2, std::layout_left, std::layout_stride>(); // { dg-error "required from" } -B<3, std::layout_right, std::layout_right> b2; // { dg-error "required here" } -B<4, std::layout_right, std::layout_stride> b3; // { dg-error "required here" } +auto b3 = B<3, std::layout_right, std::layout_right>(); // { dg-error "required from" } +auto b4 = B<4, std::layout_right, std::layout_stride>(); // { dg-error "required from" } -B<5, std::layout_stride, std::layout_right> b4; // { dg-error "required here" } -B<6, std::layout_stride, std::layout_left> b5; // { dg-error "required here" } -B<7, std::layout_stride, std::layout_stride> b6; // { dg-error "required here" } +auto b5 = B<5, std::layout_stride, std::layout_right>(); // { dg-error "required from" } +auto b6 = B<6, std::layout_stride, std::layout_left>(); // { dg-error "required from" } +auto b7 = B<7, std::layout_stride, std::layout_stride>(); // { dg-error "required from" } // { dg-prune-output "must be representable as index_type" } -- 2.47.2