[gcc r16-3808] libstdc++: Use consteval for _S_noexcept() helper functions

Jonathan Wakely redi@gcc.gnu.org
Thu Sep 11 13:39:26 GMT 2025


https://gcc.gnu.org/g:d99c6786c3ea083cdc70fa012674db58cc91079f

commit r16-3808-gd99c6786c3ea083cdc70fa012674db58cc91079f
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Thu Sep 11 09:55:12 2025 +0100

    libstdc++: Use consteval for _S_noexcept() helper functions
    
    These _S_noexcept() functions are only used in noexcept-specifiers and
    never need to be called at runtime. They can be immediate functions,
    i.e. consteval.
    
    libstdc++-v3/ChangeLog:
    
            * include/bits/iterator_concepts.h (_IterMove::_S_noexcept)
            (_IterSwap::_S_noexcept): Change constexpr to consteval.
            * include/bits/ranges_base.h (_Begin::_S_noexcept)
            (_End::_S_noexcept, _RBegin::_S_noexcept, _REnd::_S_noexcept)
            (_Size::_S_noexcept, _Empty::_S_noexcept, _Data::_S_noexcept):
            Likewise.
            * include/std/concepts (_Swap::_S_noexcept): Likewise.
    
    Reviewed-by: Tomasz Kamiński <tkaminsk@redhat.com>

Diff:
---
 libstdc++-v3/include/bits/iterator_concepts.h |  4 ++--
 libstdc++-v3/include/bits/ranges_base.h       | 14 +++++++-------
 libstdc++-v3/include/std/concepts             |  2 +-
 3 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/libstdc++-v3/include/bits/iterator_concepts.h b/libstdc++-v3/include/bits/iterator_concepts.h
index 979039e7da53..fd91b22d75a5 100644
--- a/libstdc++-v3/include/bits/iterator_concepts.h
+++ b/libstdc++-v3/include/bits/iterator_concepts.h
@@ -148,7 +148,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 	  };
 
 	template<typename _Tp>
-	  static constexpr bool
+	  static consteval bool
 	  _S_noexcept()
 	  {
 	    if constexpr (__adl_imove<_Tp>)
@@ -884,7 +884,7 @@ namespace ranges
     {
     private:
       template<typename _Tp, typename _Up>
-	static constexpr bool
+	static consteval bool
 	_S_noexcept()
 	{
 	  if constexpr (__adl_iswap<_Tp, _Up>)
diff --git a/libstdc++-v3/include/bits/ranges_base.h b/libstdc++-v3/include/bits/ranges_base.h
index 691a181bd296..27829086a351 100644
--- a/libstdc++-v3/include/bits/ranges_base.h
+++ b/libstdc++-v3/include/bits/ranges_base.h
@@ -106,7 +106,7 @@ namespace ranges
     {
     private:
       template<typename _Tp>
-	static constexpr bool
+	static consteval bool
 	_S_noexcept()
 	{
 	  if constexpr (is_array_v<remove_reference_t<_Tp>>)
@@ -157,7 +157,7 @@ namespace ranges
     {
     private:
       template<typename _Tp>
-	static constexpr bool
+	static consteval bool
 	_S_noexcept()
 	{
 	  if constexpr (is_bounded_array_v<remove_reference_t<_Tp>>)
@@ -214,7 +214,7 @@ namespace ranges
     {
     private:
       template<typename _Tp>
-	static constexpr bool
+	static consteval bool
 	_S_noexcept()
 	{
 	  if constexpr (__member_rbegin<_Tp>)
@@ -272,7 +272,7 @@ namespace ranges
     {
     private:
       template<typename _Tp>
-	static constexpr bool
+	static consteval bool
 	_S_noexcept()
 	{
 	  if constexpr (__member_rend<_Tp>)
@@ -342,7 +342,7 @@ namespace ranges
     {
     private:
       template<typename _Tp>
-	static constexpr bool
+	static consteval bool
 	_S_noexcept()
 	{
 	  if constexpr (is_bounded_array_v<remove_reference_t<_Tp>>)
@@ -422,7 +422,7 @@ namespace ranges
     {
     private:
       template<typename _Tp>
-	static constexpr bool
+	static consteval bool
 	_S_noexcept()
 	{
 	  if constexpr (__member_empty<_Tp>)
@@ -468,7 +468,7 @@ namespace ranges
     {
     private:
       template<typename _Tp>
-	static constexpr bool
+	static consteval bool
 	_S_noexcept()
 	{
 	  if constexpr (__member_data<_Tp>)
diff --git a/libstdc++-v3/include/std/concepts b/libstdc++-v3/include/std/concepts
index 5899f032434a..d9920a8f20a8 100644
--- a/libstdc++-v3/include/std/concepts
+++ b/libstdc++-v3/include/std/concepts
@@ -204,7 +204,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       {
       private:
 	template<typename _Tp, typename _Up>
-	  static constexpr bool
+	  static consteval bool
 	  _S_noexcept()
 	  {
 	    if constexpr (__adl_swap<_Tp, _Up>)


More information about the Libstdc++-cvs mailing list