[PATCH v2 09/10] libstdc++: remove __glibcxx_padded_layouts.
Luc Grosheintz
luc.grosheintz@gmail.com
Tue Nov 18 14:25:00 GMT 2025
The standard uses the same feature testing macro for both padded layouts
and submdspan. Since submdspan support is complete, we can now remove
the internal feature testing macro.
libstdc++-v3/ChangeLog:
* include/bits/version.def (padded_layouts): Remove internal
feature testing macro.
* include/bits/version.h: Regenerate.
* include/std/mdspan: Replace __glibcxx_padded_layouts with
__glibcxx_submdspan.
* src/c++23/std.cc.in: Ditto.
Signed-off-by: Luc Grosheintz <luc.grosheintz@gmail.com>
---
libstdc++-v3/include/bits/version.def | 10 ----------
libstdc++-v3/include/bits/version.h | 9 ---------
libstdc++-v3/include/std/mdspan | 26 +++++++++++---------------
libstdc++-v3/src/c++23/std.cc.in | 4 +---
4 files changed, 12 insertions(+), 37 deletions(-)
diff --git a/libstdc++-v3/include/bits/version.def b/libstdc++-v3/include/bits/version.def
index 29ecf15c7e3..394ebf4c989 100644
--- a/libstdc++-v3/include/bits/version.def
+++ b/libstdc++-v3/include/bits/version.def
@@ -1067,30 +1067,20 @@ ftms = {
ftms = {
name = aligned_accessor;
values = {
v = 202411;
cxxmin = 26;
extra_cond = "__glibcxx_assume_aligned "
"&& __glibcxx_is_sufficiently_aligned";
};
};
-// Purely internal macro padded layouts.
-ftms = {
- name = padded_layouts;
- no_stdname = true; // internal
- values = {
- v = 1;
- cxxmin = 26;
- };
-};
-
ftms = {
name = submdspan;
no_stdname = true; // TODO: change once complete
values = {
v = 1;
cxxmin = 26;
};
};
ftms = {
diff --git a/libstdc++-v3/include/bits/version.h b/libstdc++-v3/include/bits/version.h
index 5901d27113d..141c90d47ce 100644
--- a/libstdc++-v3/include/bits/version.h
+++ b/libstdc++-v3/include/bits/version.h
@@ -1196,29 +1196,20 @@
#if !defined(__cpp_lib_aligned_accessor)
# if (__cplusplus > 202302L) && (__glibcxx_assume_aligned && __glibcxx_is_sufficiently_aligned)
# define __glibcxx_aligned_accessor 202411L
# if defined(__glibcxx_want_all) || defined(__glibcxx_want_aligned_accessor)
# define __cpp_lib_aligned_accessor 202411L
# endif
# endif
#endif /* !defined(__cpp_lib_aligned_accessor) */
#undef __glibcxx_want_aligned_accessor
-#if !defined(__cpp_lib_padded_layouts)
-# if (__cplusplus > 202302L)
-# define __glibcxx_padded_layouts 1L
-# if defined(__glibcxx_want_all) || defined(__glibcxx_want_padded_layouts)
-# endif
-# endif
-#endif /* !defined(__cpp_lib_padded_layouts) */
-#undef __glibcxx_want_padded_layouts
-
#if !defined(__cpp_lib_submdspan)
# if (__cplusplus > 202302L)
# define __glibcxx_submdspan 1L
# if defined(__glibcxx_want_all) || defined(__glibcxx_want_submdspan)
# endif
# endif
#endif /* !defined(__cpp_lib_submdspan) */
#undef __glibcxx_want_submdspan
#if !defined(__cpp_lib_ssize)
diff --git a/libstdc++-v3/include/std/mdspan b/libstdc++-v3/include/std/mdspan
index 15052452425..cd2aebb4991 100644
--- a/libstdc++-v3/include/std/mdspan
+++ b/libstdc++-v3/include/std/mdspan
@@ -660,21 +660,21 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
template<typename _Extents>
class mapping;
};
struct layout_stride
{
template<typename _Extents>
class mapping;
};
-#ifdef __glibcxx_padded_layouts
+#ifdef __glibcxx_submdspan
template<size_t _PaddingValue>
struct layout_left_padded
{
template<typename _Extents>
class mapping;
};
template<size_t _PaddingValue>
struct layout_right_padded
{
@@ -783,21 +783,21 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
template<typename _Layout, typename _Mapping>
concept __mapping_of =
is_same_v<typename _Layout::template mapping<
typename _Mapping::extents_type>,
_Mapping>;
template<template<size_t> typename _Layout, typename _Mapping>
concept __padded_mapping_of = __mapping_of<
_Layout<_Mapping::padding_value>, _Mapping>;
-#ifdef __glibcxx_padded_layouts
+#ifdef __glibcxx_submdspan
template<typename _Mapping>
constexpr bool __is_left_padded_mapping = __padded_mapping_of<
layout_left_padded, _Mapping>;
template<typename _Mapping>
constexpr bool __is_right_padded_mapping = __padded_mapping_of<
layout_right_padded, _Mapping>;
template<typename _Mapping>
constexpr bool __is_padded_mapping = __is_left_padded_mapping<_Mapping>
@@ -806,21 +806,21 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
template<typename _PaddedMapping>
consteval size_t
__get_static_stride()
{ return _PaddedMapping::_PaddedStorage::_S_static_stride; }
template<typename _Mapping>
concept __standardized_mapping = __mapping_of<layout_left, _Mapping>
|| __mapping_of<layout_right, _Mapping>
|| __mapping_of<layout_stride, _Mapping>
-#ifdef __glibcxx_padded_layouts
+#ifdef __glibcxx_submdspan
|| __is_left_padded_mapping<_Mapping>
|| __is_right_padded_mapping<_Mapping>
#endif
;
// A tag type to create internal ctors.
class __internal_ctor
{ };
template<typename _Mapping>
@@ -1558,21 +1558,21 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
{ }
// noexcept for consistency with other layouts.
template<typename _OExtents>
requires is_constructible_v<extents_type, _OExtents>
constexpr explicit(extents_type::rank() > 0)
mapping(const layout_stride::mapping<_OExtents>& __other) noexcept
: mapping(__other.extents(), __mdspan::__internal_ctor{})
{ __glibcxx_assert(*this == __other); }
-#if __glibcxx_padded_layouts
+#if __glibcxx_submdspan
template<typename _LeftpadMapping>
requires __mdspan::__is_left_padded_mapping<_LeftpadMapping>
&& is_constructible_v<extents_type,
typename _LeftpadMapping::extents_type>
constexpr
explicit(!is_convertible_v<typename _LeftpadMapping::extents_type,
extents_type>)
mapping(const _LeftpadMapping& __other) noexcept
: mapping(__other.extents(), __mdspan::__internal_ctor{})
{
@@ -1582,21 +1582,21 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
if constexpr (extents_type::rank() > 1)
{
if constexpr (extents_type::static_extent(0) != dynamic_extent
&& __ostride_sta != dynamic_extent)
static_assert(extents_type::static_extent(0) == __ostride_sta);
else
__glibcxx_assert(__other.stride(1)
== __other.extents().extent(0));
}
}
-#endif // __glibcxx_padded_layouts
+#endif
constexpr mapping&
operator=(const mapping&) noexcept = default;
constexpr const extents_type&
extents() const noexcept { return _M_extents; }
constexpr index_type
required_span_size() const noexcept
{ return __mdspan::__size(_M_extents); }
@@ -1655,21 +1655,21 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
"The size of OtherExtents must be representable as index_type");
__glibcxx_assert(__mdspan::__is_representable_extents(_M_extents));
}
#if __glibcxx_submdspan
template<__mdspan::__valid_canonical_slice_type<index_type>... _Slices>
requires (extents_type::rank() == sizeof...(_Slices))
friend constexpr auto
submdspan_mapping(const mapping& __mapping, _Slices... __slices)
{ return __mdspan::__submdspan_mapping_impl(__mapping, __slices...); }
-#endif // __glibcxx_submdspan
+#endif
[[no_unique_address]] extents_type _M_extents{};
};
namespace __mdspan
{
template<typename _Extents, typename... _Indices>
constexpr typename _Extents::index_type
__linear_index_right(const _Extents& __exts, _Indices... __indices)
noexcept
@@ -1733,21 +1733,21 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
: mapping(__other.extents(), __mdspan::__internal_ctor{})
{ }
template<typename _OExtents>
requires is_constructible_v<extents_type, _OExtents>
constexpr explicit(extents_type::rank() > 0)
mapping(const layout_stride::mapping<_OExtents>& __other) noexcept
: mapping(__other.extents(), __mdspan::__internal_ctor{})
{ __glibcxx_assert(*this == __other); }
-#if __glibcxx_padded_layouts
+#if __glibcxx_submdspan
template<typename _RightPaddedMapping>
requires __mdspan::__is_right_padded_mapping<_RightPaddedMapping>
&& is_constructible_v<extents_type,
typename _RightPaddedMapping::extents_type>
constexpr
explicit(!is_convertible_v<typename _RightPaddedMapping::extents_type,
extents_type>)
mapping(const _RightPaddedMapping& __other) noexcept
: mapping(__other.extents(), __mdspan::__internal_ctor{})
{
@@ -1833,27 +1833,27 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
template<typename _OExtents>
constexpr explicit
mapping(const _OExtents& __oexts, __mdspan::__internal_ctor) noexcept
: _M_extents(__oexts)
{
static_assert(__mdspan::__representable_size<_OExtents, index_type>,
"The size of OtherExtents must be representable as index_type");
__glibcxx_assert(__mdspan::__is_representable_extents(_M_extents));
}
-#if __glibcxx_padded_layouts
+#if __glibcxx_submdspan
template<__mdspan::__valid_canonical_slice_type<index_type>... _Slices>
requires (extents_type::rank() == sizeof...(_Slices))
friend constexpr auto
submdspan_mapping(const mapping& __mapping, _Slices... __slices)
{ return __mdspan::__submdspan_mapping_impl(__mapping, __slices...); }
-#endif // __glibcxx_submdspan
+#endif
[[no_unique_address]] extents_type _M_extents{};
};
namespace __mdspan
{
template<typename _Mp>
concept __mapping_alike = requires
{
requires __is_extents<typename _Mp::extents_type>;
@@ -2082,21 +2082,21 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
submdspan_mapping(const mapping& __mapping, _Slices... __slices)
{ return __mapping._M_submdspan_mapping_impl(__slices...); }
#endif
using _Strides = typename __array_traits<index_type,
extents_type::rank()>::_Type;
[[no_unique_address]] extents_type _M_extents;
[[no_unique_address]] _Strides _M_strides;
};
-#ifdef __glibcxx_padded_layouts
+#ifdef __glibcxx_submdspan
namespace __mdspan
{
constexpr size_t
__least_multiple(size_t __x, size_t __y)
{
if (__x <= 1)
return __y;
return (__y / __x + (__y % __x != 0)) * __x ;
}
@@ -2684,27 +2684,25 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
template<typename _LeftpadMapping>
requires(__mdspan::__is_left_padded_mapping<_LeftpadMapping>
&& _LeftpadMapping::extents_type::rank() == _S_rank)
friend constexpr bool
operator==(const mapping& __self, const _LeftpadMapping& __other)
noexcept
{ return __self._M_storage._M_equal(__other); }
private:
-#if __glibcxx_submdspan
template<__mdspan::__valid_canonical_slice_type<index_type>... _Slices>
requires (extents_type::rank() == sizeof...(_Slices))
friend constexpr auto
submdspan_mapping(const mapping& __mapping, _Slices... __slices)
{ return __mdspan::__submdspan_mapping_impl(__mapping, __slices...); }
-#endif // __glibcxx_submdspan
};
template<size_t _PaddingValue>
template<typename _Extents>
class layout_right_padded<_PaddingValue>::mapping {
public:
static constexpr size_t padding_value = _PaddingValue;
using extents_type = _Extents;
using index_type = typename extents_type::index_type;
using size_type = typename extents_type::size_type;
@@ -2857,30 +2855,28 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
}
template<typename _RightPaddedMapping>
requires(__mdspan::__is_right_padded_mapping<_RightPaddedMapping>
&& _RightPaddedMapping::extents_type::rank() == _S_rank)
friend constexpr bool
operator==(const mapping& __self, const _RightPaddedMapping& __other)
noexcept
{ return __self._M_storage._M_equal(__other); }
-#if __glibcxx_submdspan
private:
template<__mdspan::__valid_canonical_slice_type<index_type>... _Slices>
requires (extents_type::rank() == sizeof...(_Slices))
friend constexpr auto
submdspan_mapping(const mapping& __mapping, _Slices... __slices)
{ return __mdspan::__submdspan_mapping_impl(__mapping, __slices...); }
-#endif // __glibcxx_submdspan
};
-#endif // __glibcxx_padded_layouts
+#endif // __glibcxx_submdspan
template<typename _ElementType>
struct default_accessor
{
static_assert(!is_array_v<_ElementType>,
"ElementType must not be an array type");
static_assert(!is_abstract_v<_ElementType>,
"ElementType must not be an abstract class type");
using offset_policy = default_accessor;
diff --git a/libstdc++-v3/src/c++23/std.cc.in b/libstdc++-v3/src/c++23/std.cc.in
index 2dac6a6d887..411db19f616 100644
--- a/libstdc++-v3/src/c++23/std.cc.in
+++ b/libstdc++-v3/src/c++23/std.cc.in
@@ -1867,25 +1867,23 @@ export namespace std
using std::dims;
#endif
using std::layout_left;
using std::layout_right;
using std::layout_stride;
using std::default_accessor;
#if __glibcxx_aligned_accessor
using std::aligned_accessor;
#endif
using std::mdspan;
-#if __glibcxx_padded_layouts
+#if __glibcxx_submdspan
using std::layout_left_padded;
using std::layout_right_padded;
-#endif
-#if __glibcxx_submdspan
using std::strided_slice;
using std::full_extent_t;
using std::full_extent;
using std::submdspan_mapping_result;
using std::submdspan_canonicalize_slices;
using std::submdspan_extents;
using std::submdspan;
#endif
}
#endif
--
2.51.2
More information about the Libstdc++
mailing list