Skip to content

Commit

Permalink
libstdc++: Optimize is_compound trait performance
Browse files Browse the repository at this point in the history
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): Use __is_arithmetic
	built-in trait.
	(is_compound_v): Use is_fundamental_v instead.

Signed-off-by: Ken Matsui <kmatsui@gcc.gnu.org>
  • Loading branch information
ken-matsui authored and ouuleilei-bot committed Jul 18, 2023
1 parent 61379be commit cc1f9c3
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion libstdc++-v3/include/std/type_traits
Original file line number Diff line number Diff line change
Expand Up @@ -702,9 +702,18 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
{ };

/// is_compound
#if __has_builtin(__is_arithmetic)
template<typename _Tp>
struct is_compound
: public __bool_constant<!(__is_arithmetic(_Tp)
|| is_void<_Tp>::value
|| is_null_pointer<_Tp>::value)>
{ };
#else
template<typename _Tp>
struct is_compound
: public __not_<is_fundamental<_Tp>>::type { };
#endif

/// @cond undocumented
template<typename _Tp>
Expand Down Expand Up @@ -3234,7 +3243,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>
Expand Down

0 comments on commit cc1f9c3

Please sign in to comment.