[PATCH] libsdc++: Remove duplicated __mdspan::__is_constant_wrapper.

Tomasz Kamiński tkaminsk@redhat.com
Thu Apr 30 18:18:19 GMT 2026


Replaced it with std::__is_constant_wrapper_v from utility.

libstdc++-v3/ChangeLog:

	* include/std/mdspan: Replace eight spaces with tabs.
	(__mdspan::__is_constant_wrapper): Remove.
	(__mdspan::__acceptable_slice_type, __mdspan::__static_slice_extent)
	(__mdspan::__is_unit_stride_slice, __mdspan::__canonical_range_slice)
	(__mdspan::__check_inrange_index, __mdspan::__check_valid_index)
	(__mdspan::__check_valid_slice, std::submdspan): Replace
	__mdspan::__is_constant_wrapper with std::__is_constant_wrapper_v.
---
Testing on x86_64-linux. *mdspan* test already passed.
OK for trunk?

 libstdc++-v3/include/std/mdspan | 69 +++++++++++++++------------------
 1 file changed, 31 insertions(+), 38 deletions(-)

diff --git a/libstdc++-v3/include/std/mdspan b/libstdc++-v3/include/std/mdspan
index a3ab64633ac..5938bf09a94 100644
--- a/libstdc++-v3/include/std/mdspan
+++ b/libstdc++-v3/include/std/mdspan
@@ -838,7 +838,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 
     template<typename _Mapping>
       constexpr bool __is_padded_mapping = __is_left_padded_mapping<_Mapping>
-        || __is_right_padded_mapping<_Mapping>;
+	|| __is_right_padded_mapping<_Mapping>;
 #endif
 
     template<typename _PaddedMapping>
@@ -904,13 +904,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 	    && std::cmp_less_equal(__value, __max);
       }
 
-    template<typename _Tp>
-      constexpr bool __is_constant_wrapper = false;
-
-    template<_CwFixedValue _Xv, typename _Tp>
-      constexpr bool __is_constant_wrapper<constant_wrapper<_Xv, _Tp>>
-	= true;
-
     template<size_t _Index, typename _Extents>
       constexpr auto
       __extract_extent(const _Extents& __exts)
@@ -922,7 +915,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 
     template<typename _Slice, typename _IndexType>
       concept __acceptable_slice_type = same_as<_Slice, full_extent_t>
-	  || same_as<_Slice, _IndexType> || __is_constant_wrapper<_Slice>
+	  || same_as<_Slice, _IndexType> || __is_constant_wrapper_v<_Slice>
 	  || __is_extent_slice<_Slice>;
 
     template<typename _IndexType, typename... _Slices>
@@ -1003,7 +996,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 	  return _Extent;
 	else if constexpr (same_as<_Slice, constant_wrapper<_IndexType(0)>>)
 	  return 0;
-	else if constexpr (__is_constant_wrapper<typename _Slice::extent_type>)
+	else if constexpr (__is_constant_wrapper_v<typename _Slice::extent_type>)
 	  return _Slice::extent_type::value;
 	else
 	  return dynamic_extent;
@@ -1204,7 +1197,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 
     template<typename _Slice>
       concept __is_unit_stride_slice = (__mdspan::__is_extent_slice<_Slice>
-	  && __mdspan::__is_constant_wrapper<typename _Slice::stride_type>
+	  && __is_constant_wrapper_v<typename _Slice::stride_type>
 	  && _Slice::stride_type::value == 1)
 	|| std::same_as<_Slice, full_extent_t>;
 
@@ -1534,7 +1527,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       template<typename _OExtents>
 	requires is_constructible_v<extents_type, _OExtents>
 	constexpr explicit(!(extents_type::rank() == 0
-	                     && is_convertible_v<_OExtents, extents_type>))
+			     && is_convertible_v<_OExtents, extents_type>))
 	mapping(const layout_stride::mapping<_OExtents>& __other) noexcept
 	: mapping(__other.extents(), __mdspan::__internal_ctor{})
 	{ __glibcxx_assert(*this == __other); }
@@ -1710,7 +1703,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       template<typename _OExtents>
 	requires is_constructible_v<extents_type, _OExtents>
 	constexpr explicit(!(extents_type::rank() == 0
-	                     && is_convertible_v<_OExtents, extents_type>))
+			     && is_convertible_v<_OExtents, extents_type>))
 	mapping(const layout_stride::mapping<_OExtents>& __other) noexcept
 	: mapping(__other.extents(), __mdspan::__internal_ctor{})
 	{ __glibcxx_assert(*this == __other); }
@@ -3308,10 +3301,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 	  .extent = __span,
 	  .stride = cw<_IndexType(1)>
 	};
-      else if constexpr (__is_constant_wrapper<_StrideType>)
-        {
+      else if constexpr (__is_constant_wrapper_v<_StrideType>)
+	{
 	  static_assert(_StrideType::value > 0);
-	  if constexpr (__is_constant_wrapper<_SpanType>)
+	  if constexpr (__is_constant_wrapper_v<_SpanType>)
 	    return extent_slice{
 	      .offset = __offset,
 	      .extent = cw<_IndexType(1 + (_SpanType::value - 1) / _StrideType::value)>,
@@ -3323,7 +3316,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 	      .extent = _IndexType(__span > 0 ? 1 + (__span - 1) / _StrideType::value : 0),
 	      .stride = __stride
 	    };
-        }
+	}
       else if (__span == 0 || __stride == 1)
 	return extent_slice{
 	  .offset = __offset,
@@ -3331,7 +3324,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 	  .stride = _IndexType(1)
 	};
       else
-        {
+	{
 	  __glibcxx_assert(__stride > 0);
 	  return extent_slice{
 	    .offset = __offset,
@@ -3386,7 +3379,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       __check_inrange_index(const extents<_IndexType, _Extent>& __ext,
 			   const _OIndexType& __idx)
       {
-	if constexpr (__is_constant_wrapper<_OIndexType>
+	if constexpr (__is_constant_wrapper_v<_OIndexType>
 		      && _Extent != dynamic_extent)
 	  {
 	    static_assert(_OIndexType::value >= 0);
@@ -3401,7 +3394,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       __check_valid_index(const extents<_IndexType, _Extent>& __ext,
 			   const _OIndexType& __idx)
       {
-	if constexpr (__is_constant_wrapper<_OIndexType>
+	if constexpr (__is_constant_wrapper_v<_OIndexType>
 		      && _Extent != dynamic_extent)
 	  {
 	    static_assert(_OIndexType::value >= 0);
@@ -3427,31 +3420,31 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 				    constant_wrapper<_IndexType(0)>>)
 	      __mdspan::__check_valid_index(__ext, __slice.offset);
 	    else if constexpr (is_same_v<typename _Slice::extent_type,
-				         constant_wrapper<_IndexType(1)>>)
-              __mdspan::__check_inrange_index(__ext, __slice.offset);
-	    else if constexpr (__is_constant_wrapper<typename _Slice::extent_type>)
+					 constant_wrapper<_IndexType(1)>>)
+	      __mdspan::__check_inrange_index(__ext, __slice.offset);
+	    else if constexpr (__is_constant_wrapper_v<typename _Slice::extent_type>)
 	      { 
-              	__mdspan::__check_inrange_index(__ext, __slice.offset);
-		if constexpr (__is_constant_wrapper<typename _Slice::stride_type>)
+	      	__mdspan::__check_inrange_index(__ext, __slice.offset);
+		if constexpr (__is_constant_wrapper_v<typename _Slice::stride_type>)
 		  static_assert(_Slice::stride_type::value > 0);
 		else
 		  __glibcxx_assert(__slice.stride > 0);
 
 		if constexpr (_Extent != dynamic_extent
-		     && __is_constant_wrapper<typename _Slice::offset_type>)
-                  static_assert(std::cmp_greater_equal(
+		     && __is_constant_wrapper_v<typename _Slice::offset_type>)
+		  static_assert(std::cmp_greater_equal(
 		    _Extent - _Slice::offset_type::value,
 		    _Slice::extent_type::value));
 		if constexpr (_Extent != dynamic_extent
-		     && __is_constant_wrapper<typename _Slice::stride_type>)
-                  static_assert(std::cmp_greater(
+		     && __is_constant_wrapper_v<typename _Slice::stride_type>)
+		  static_assert(std::cmp_greater(
 		    _Extent,
 		    (_Slice::extent_type::value - 1) * _Slice::stride_type::value));
 
 		if constexpr (_Extent != dynamic_extent
-		     && __is_constant_wrapper<typename _Slice::offset_type>
-	             && __is_constant_wrapper<typename _Slice::stride_type>)
-                  static_assert(std::cmp_greater(
+		     && __is_constant_wrapper_v<typename _Slice::offset_type>
+		     && __is_constant_wrapper_v<typename _Slice::stride_type>)
+		  static_assert(std::cmp_greater(
 		    _Extent - _Slice::offset_type::value,
 		    (_Slice::extent_type::value - 1) * _Slice::stride_type::value));
 		else
@@ -3460,18 +3453,18 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 		    (_Slice::extent_type::value - 1) * __slice.stride));
 	      }
 	    else if constexpr (is_same_v<typename _Slice::stride_type,
-                                         constant_wrapper<_IndexType(1)>>)
+				         constant_wrapper<_IndexType(1)>>)
 	      {
-	        __mdspan::__check_valid_index(__ext, __slice.offset);
+		__mdspan::__check_valid_index(__ext, __slice.offset);
 		__glibcxx_assert(std::cmp_greater_equal(
 		  __ext.extent(0) - __slice.offset,
 		  __slice.extent));
-              }
+	      }
 	    else if (__slice.extent == 0)
 	      __mdspan::__check_valid_index(__ext, __slice.offset);
 	    else
 	      {
-	        __glibcxx_assert(__slice.offset < __ext.extent(0));
+		__glibcxx_assert(__slice.offset < __ext.extent(0));
 		__glibcxx_assert(__slice.extent == 1 || __slice.stride > 0);
 		__glibcxx_assert(__slice.extent == 1 || std::cmp_greater(
 		  __ext.extent(0) - __slice.offset,
@@ -3479,7 +3472,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 	      }
 	  }
 	else if constexpr (!is_same_v<_Slice, full_extent_t>)
-          __mdspan::__check_inrange_index(__ext, __slice);
+	  __mdspan::__check_inrange_index(__ext, __slice);
       }
 
     template<typename _Extents, typename... _Slices>
@@ -3548,7 +3541,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 	   typename _Accessor, typename... _RawSlices>
     requires (sizeof...(_RawSlices) == _Extents::rank()
 	&& __mdspan::__sliceable_mapping<typename _Layout::template mapping<_Extents>,
-	                                 __mdspan::__full_extent_t<_RawSlices>...>)
+					 __mdspan::__full_extent_t<_RawSlices>...>)
     constexpr auto
     submdspan(
 	const mdspan<_ElementType, _Extents, _Layout, _Accessor>& __md,
-- 
2.54.0



More information about the Libstdc++ mailing list