Hi,

I'm attaching a very small cleanup for constexpr std::stable_sort, using `if consteval` instead of `__is_constant_evaluated` within a C++26 feature.

Thanks,
--
Giuseppe D'Angelo
From d81ed6c0e5eb8b4bce831217bafdf71c183b1ffa Mon Sep 17 00:00:00 2001
From: Giuseppe D'Angelo <giuseppe.dang...@kdab.com>
Date: Wed, 5 Mar 2025 14:34:41 +0100
Subject: [PATCH] libstdc++: use if consteval in stable_sort

This is a C++ >= 26 codepath for supporting constexpr stable_sort, so we
know that we have if consteval available; it just needs protection with
the feature-testing macro. Also merge the return in the same statement.
Amends r15-7708-gff43f9853d3b10.

libstdc++-v3/ChangeLog:

	* include/bits/stl_algo.h (__stable_sort): Use if consteval
	instead of is_constant_evaluated.

Signed-off-by: Giuseppe D'Angelo <giuseppe.dang...@kdab.com>
---
 libstdc++-v3/include/bits/stl_algo.h | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/libstdc++-v3/include/bits/stl_algo.h b/libstdc++-v3/include/bits/stl_algo.h
index 41b4d0853b7..c3fea76014c 100644
--- a/libstdc++-v3/include/bits/stl_algo.h
+++ b/libstdc++-v3/include/bits/stl_algo.h
@@ -4987,11 +4987,11 @@ _GLIBCXX_BEGIN_NAMESPACE_ALGO
 	return;
 
 #if _GLIBCXX_HOSTED
-      if (__is_constant_evaluated())
-	{
-	  std::__inplace_stable_sort(__first, __last, __comp);
-	  return;
-	}
+# if __glibcxx_constexpr_algorithms >= 202306L // >= C++26
+      if consteval {
+	return std::__inplace_stable_sort(__first, __last, __comp);
+      }
+# endif
 
       typedef _Temporary_buffer<_RandomAccessIterator, _ValueType> _TmpBuf;
       // __stable_sort_adaptive sorts the range in two halves,
-- 
2.34.1

Attachment: smime.p7s
Description: S/MIME Cryptographic Signature

Reply via email to