[v5,4/4] libstdc++: Optimize is_compound trait performance

Message ID 20230901112510.1562-4-kmatsui@gcc.gnu.org
State Accepted
Headers
Series [v5,1/4] c++, libstdc++: Implement __is_arithmetic built-in trait |

Checks

Context Check Description
snail/gcc-patch-check success Github commit url

Commit Message

Ken Matsui Sept. 1, 2023, 11:25 a.m. UTC
  This patch optimizes the performance of the is_compound trait by
dispatching to the new __is_arithmetic built-in trait.

libstdc++-v3/ChangeLog:

	* include/std/type_traits (is_compound): Do not use __not_.
	(is_compound_v): Use is_fundamental_v instead.

Signed-off-by: Ken Matsui <kmatsui@gcc.gnu.org>
---
 libstdc++-v3/include/std/type_traits | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
  

Patch

diff --git a/libstdc++-v3/include/std/type_traits b/libstdc++-v3/include/std/type_traits
index cf24de2fcac..531f5a2bb3a 100644
--- a/libstdc++-v3/include/std/type_traits
+++ b/libstdc++-v3/include/std/type_traits
@@ -704,7 +704,7 @@  _GLIBCXX_BEGIN_NAMESPACE_VERSION
   /// is_compound
   template<typename _Tp>
     struct is_compound
-    : public __not_<is_fundamental<_Tp>>::type { };
+    : public __bool_constant<!is_fundamental<_Tp>::value> { };
 
   /// @cond undocumented
   template<typename _Tp>
@@ -3234,7 +3234,7 @@  template <typename _Tp>
 template <typename _Tp>
   inline constexpr bool is_scalar_v = is_scalar<_Tp>::value;
 template <typename _Tp>
-  inline constexpr bool is_compound_v = is_compound<_Tp>::value;
+  inline constexpr bool is_compound_v = !is_fundamental_v<_Tp>;
 template <typename _Tp>
   inline constexpr bool is_member_pointer_v = is_member_pointer<_Tp>::value;
 template <typename _Tp>