Skip to content

Commit

Permalink
libstdc++: Optimize is_member_pointer trait performance
Browse files Browse the repository at this point in the history
This patch optimizes the performance of the is_member_pointer trait
by dispatching to the new __is_member_pointer built-in trait.

libstdc++-v3/ChangeLog:

	* include/std/type_traits (is_member_pointer): Use __is_member_pointer
	built-in trait.
	(is_member_pointer_v): Likewise.

Signed-off-by: Ken Matsui <kmatsui@gcc.gnu.org>
  • Loading branch information
ken-matsui authored and ouuleilei-bot committed Sep 12, 2023
1 parent 7351f86 commit eea6f7d
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion libstdc++-v3/include/std/type_traits
Original file line number Diff line number Diff line change
Expand Up @@ -689,6 +689,13 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
struct is_compound
: public __not_<is_fundamental<_Tp>>::type { };

/// is_member_pointer
#if _GLIBCXX_USE_BUILTIN_TRAIT(__is_member_pointer)
template<typename _Tp>
struct is_member_pointer
: public __bool_constant<__is_member_pointer(_Tp)>
{ };
#else
/// @cond undocumented
template<typename _Tp>
struct __is_member_pointer_helper
Expand All @@ -699,11 +706,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
: public true_type { };
/// @endcond

/// is_member_pointer
template<typename _Tp>
struct is_member_pointer
: public __is_member_pointer_helper<__remove_cv_t<_Tp>>::type
{ };
#endif

template<typename, typename>
struct is_same;
Expand Down Expand Up @@ -3208,8 +3215,15 @@ 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;

#if _GLIBCXX_USE_BUILTIN_TRAIT(__is_member_pointer)
template <typename _Tp>
inline constexpr bool is_member_pointer_v = __is_member_pointer(_Tp);
#else
template <typename _Tp>
inline constexpr bool is_member_pointer_v = is_member_pointer<_Tp>::value;
#endif

template <typename _Tp>
inline constexpr bool is_const_v = false;
template <typename _Tp>
Expand Down

0 comments on commit eea6f7d

Please sign in to comment.