[gcc r17-36] libstdc++: Implement __integral_constant_like in terms of __constexpr_wrapper_like.
Tomasz Kaminski
tkaminsk@gcc.gnu.org
Thu Apr 23 10:28:06 GMT 2026
https://gcc.gnu.org/g:2653c165822ee49a5ff21c24bdee42a52452265f
commit r17-36-g2653c165822ee49a5ff21c24bdee42a52452265f
Author: Tomasz Kamiński <tkaminsk@redhat.com>
Date: Tue Apr 21 14:34:40 2026 +0200
libstdc++: Implement __integral_constant_like in terms of __constexpr_wrapper_like.
This implements LWG4486. integral-constant-like and constexpr-wrapper-like
exposition-only concept duplication.
libstdc++-v3/ChangeLog:
* include/bits/simd_details.h (simd::__constexpr_wrapper_like):
Move to...
* include/std/concepts (std::__constexpr_wrapper_like): Moved
from bits/simd_details.h.
* include/std/span (std::__integral_constant_like): Define in
terms of __constexpr_wrapper_like.
* testsuite/std/simd/traits_impl.cc: Added using declaration
for std::__constexpr_wrapper_like.
Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
Signed-off-by: Tomasz Kamiński <tkaminsk@redhat.com>
Diff:
---
libstdc++-v3/include/bits/simd_details.h | 7 -------
libstdc++-v3/include/std/concepts | 9 +++++++++
libstdc++-v3/include/std/span | 8 +++-----
libstdc++-v3/testsuite/std/simd/traits_impl.cc | 1 +
4 files changed, 13 insertions(+), 12 deletions(-)
diff --git a/libstdc++-v3/include/bits/simd_details.h b/libstdc++-v3/include/bits/simd_details.h
index 3880d8a19166..a1acc5bd9464 100644
--- a/libstdc++-v3/include/bits/simd_details.h
+++ b/libstdc++-v3/include/bits/simd_details.h
@@ -1030,13 +1030,6 @@ namespace simd
/** @internal
* C++26 [simd.expos]
*/
- template<typename _Tp>
- concept __constexpr_wrapper_like
- = convertible_to<_Tp, decltype(_Tp::value)>
- && equality_comparable_with<_Tp, decltype(_Tp::value)>
- && bool_constant<_Tp() == _Tp::value>::value
- && bool_constant<static_cast<decltype(_Tp::value)>(_Tp()) == _Tp::value>::value;
-
// [simd.ctor] explicit(...) of broadcast ctor
template <auto _From, typename _To>
concept __non_narrowing_constexpr_conversion
diff --git a/libstdc++-v3/include/std/concepts b/libstdc++-v3/include/std/concepts
index 7673443f33a8..328096a89e38 100644
--- a/libstdc++-v3/include/std/concepts
+++ b/libstdc++-v3/include/std/concepts
@@ -421,6 +421,15 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
&& ! requires(_Tp&& __t, _Up&& __u)
{ static_cast<_Up&&>(__u).operator<=>(static_cast<_Tp&&>(__t)); }));
}
+
+ // [expos.only.entity]
+ template<typename _Tp>
+ concept __constexpr_wrapper_like
+ = convertible_to<_Tp, decltype(_Tp::value)>
+ && equality_comparable_with<_Tp, decltype(_Tp::value)>
+ && bool_constant<_Tp() == _Tp::value>::value
+ && bool_constant<static_cast<decltype(_Tp::value)>(_Tp()) == _Tp::value>::value;
+
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace
#endif // __cpp_lib_concepts
diff --git a/libstdc++-v3/include/std/span b/libstdc++-v3/include/std/span
index a5f5bf48f90e..aaa7a485be8c 100644
--- a/libstdc++-v3/include/std/span
+++ b/libstdc++-v3/include/std/span
@@ -467,15 +467,13 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
{
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 4351. integral-constant-like needs more remove_cvref_t
+ // 4486. integral-constant-like and constexpr-wrapper-like exposition-only
+ // concept duplication
template<typename _Tp>
concept __integral_constant_like =
is_integral_v<remove_cvref_t<decltype(_Tp::value)>>
&& !is_same_v<bool, remove_cvref_t<decltype(_Tp::value)>>
- && convertible_to<_Tp, decltype(_Tp::value)>
- && equality_comparable_with<_Tp, decltype(_Tp::value)>
- && bool_constant<_Tp() == _Tp::value>::value
- && bool_constant<static_cast<decltype(_Tp::value)>(_Tp()) == _Tp::value>
- ::value;
+ && __constexpr_wrapper_like<_Tp>;
template<typename _Tp>
constexpr size_t __maybe_static_ext = dynamic_extent;
diff --git a/libstdc++-v3/testsuite/std/simd/traits_impl.cc b/libstdc++-v3/testsuite/std/simd/traits_impl.cc
index f73a9e3beb5b..2f705c7df2f7 100644
--- a/libstdc++-v3/testsuite/std/simd/traits_impl.cc
+++ b/libstdc++-v3/testsuite/std/simd/traits_impl.cc
@@ -16,6 +16,7 @@ using std::float32_t;
using std::float64_t;
using namespace std::simd;
+using std::__constexpr_wrapper_like;
template <int = 0>
void test()
More information about the Libstdc++-cvs
mailing list