]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
libstdc++: Make <mdspan> compatible with clang.
authorLuc Grosheintz <luc.grosheintz@gmail.com>
Wed, 19 Nov 2025 13:52:04 +0000 (14:52 +0100)
committerTomasz Kamiński <tkaminsk@redhat.com>
Wed, 19 Nov 2025 14:47:11 +0000 (15:47 +0100)
These three changes are needed to make <mdspan> compatible with Clang:

  - the type alias _Storage must occur before its first use.

  - the friend declarations of function must match exactly, including
  noexcept and constexpr.

  - the 'template' in typename T::template type<double>.

libstdc++-v3/ChangeLog:

* include/std/mdspan (extents::_Storage): Move type alias before
its first use.
(__mdspan::__static_extents): Add missing noexcept and constexpr
to friend declaration in extents.
(__mdspan::__dynamic_extents): Ditto.

Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
Signed-off-by: Luc Grosheintz <luc.grosheintz@gmail.com>
libstdc++-v3/include/std/mdspan

index d555b7f2580ade1d5b0e263aeef5866a479f4d57..bd7a2a201a74507c69b6535e423f618a51e5c62c 100644 (file)
@@ -378,6 +378,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       static_assert(
          (__mdspan::__valid_static_extent<_Extents, _IndexType> && ...),
          "Extents must either be dynamic or representable as IndexType");
+
+      using _Storage = __mdspan::_ExtentsStorage<
+       _IndexType, array<size_t, sizeof...(_Extents)>{_Extents...}>;
+      [[no_unique_address]] _Storage _M_exts;
+
     public:
       using index_type = _IndexType;
       using size_type = make_unsigned_t<index_type>;
@@ -487,15 +492,12 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
        }
 
     private:
-      friend const array<size_t, rank()>&
-      __mdspan::__static_extents<extents>();
+      friend constexpr const array<size_t, rank()>&
+      __mdspan::__static_extents<extents>() noexcept;
 
-      friend span<const index_type>
-      __mdspan::__dynamic_extents<extents>(const extents&, size_t, size_t);
-
-      using _Storage = __mdspan::_ExtentsStorage<
-       _IndexType, array<size_t, sizeof...(_Extents)>{_Extents...}>;
-      [[no_unique_address]] _Storage _M_exts;
+      friend constexpr span<const index_type>
+      __mdspan::__dynamic_extents<extents>(const extents&, size_t, size_t)
+      noexcept;
 
       template<typename _OIndexType, size_t... _OExtents>
        friend class extents;
@@ -1637,8 +1639,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 
        template<typename _OExtents>
          constexpr explicit
-         _PaddedStorage(const typename _LayoutSame::mapping<_OExtents>&
-                        __other)
+         _PaddedStorage(
+             const typename _LayoutSame::template mapping<_OExtents>& __other)
          : _PaddedStorage(_Extents(__other.extents()))
          {
            constexpr size_t __stride_idx = _LayoutTraits::_S_stride_idx;