This patch optimizes the compilation performance of
std::is_member_object_pointer by dispatching to the new
__is_member_object_pointer built-in trait.

libstdc++-v3/ChangeLog:

        * include/std/type_traits (is_member_object_pointer): Use
        __is_member_object_pointer built-in trait.
        (is_member_object_pointer_v): Likewise.

Signed-off-by: Ken Matsui <kmat...@gcc.gnu.org>
---
 libstdc++-v3/include/std/type_traits | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)

diff --git a/libstdc++-v3/include/std/type_traits 
b/libstdc++-v3/include/std/type_traits
index e1b10240dc2..792213ebfe8 100644
--- a/libstdc++-v3/include/std/type_traits
+++ b/libstdc++-v3/include/std/type_traits
@@ -574,6 +574,13 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     struct is_rvalue_reference<_Tp&&>
     : public true_type { };
 
+  /// is_member_object_pointer
+#if _GLIBCXX_USE_BUILTIN_TRAIT(__is_member_object_pointer)
+  template<typename _Tp>
+    struct is_member_object_pointer
+    : public __bool_constant<__is_member_object_pointer(_Tp)>
+    { };
+#else
   template<typename>
     struct __is_member_object_pointer_helper
     : public false_type { };
@@ -582,11 +589,12 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     struct __is_member_object_pointer_helper<_Tp _Cp::*>
     : public __not_<is_function<_Tp>>::type { };
 
-  /// is_member_object_pointer
+
   template<typename _Tp>
     struct is_member_object_pointer
     : public __is_member_object_pointer_helper<__remove_cv_t<_Tp>>::type
     { };
+#endif
 
 #if _GLIBCXX_USE_BUILTIN_TRAIT(__is_member_function_pointer)
   /// is_member_function_pointer
@@ -3227,9 +3235,16 @@ template <typename _Tp>
   inline constexpr bool is_rvalue_reference_v = false;
 template <typename _Tp>
   inline constexpr bool is_rvalue_reference_v<_Tp&&> = true;
+
+#if _GLIBCXX_USE_BUILTIN_TRAIT(__is_member_object_pointer)
+template <typename _Tp>
+  inline constexpr bool is_member_object_pointer_v =
+    __is_member_object_pointer(_Tp);
+#else
 template <typename _Tp>
   inline constexpr bool is_member_object_pointer_v =
     is_member_object_pointer<_Tp>::value;
+#endif
 
 #if _GLIBCXX_USE_BUILTIN_TRAIT(__is_member_function_pointer)
 template <typename _Tp>
-- 
2.42.0

Reply via email to