This patch optimizes the compilation performance of std::is_integral by dispatching to the new __is_integral built-in trait.
libstdc++-v3/ChangeLog: * include/std/type_traits (is_integral): Use __is_integral built-in trait. (is_integral_v): Likewise. Signed-off-by: Ken Matsui <kmat...@gcc.gnu.org> --- libstdc++-v3/include/std/type_traits | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/libstdc++-v3/include/std/type_traits b/libstdc++-v3/include/std/type_traits index 1cec0822b73..afa281d9cc4 100644 --- a/libstdc++-v3/include/std/type_traits +++ b/libstdc++-v3/include/std/type_traits @@ -334,6 +334,13 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION struct is_void<const volatile void> : public true_type { }; +#if _GLIBCXX_USE_BUILTIN_TRAIT(__is_integral) + /// is_integral + template<typename _Tp> + struct is_integral + : public __bool_constant<__is_integral(_Tp)> + { }; +#else /// @cond undocumented template<typename> struct __is_integral_helper @@ -461,6 +468,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION struct is_integral : public __is_integral_helper<__remove_cv_t<_Tp>>::type { }; +#endif /// @cond undocumented template<typename> @@ -3221,8 +3229,15 @@ template <typename _Tp> inline constexpr bool is_void_v = is_void<_Tp>::value; template <typename _Tp> inline constexpr bool is_null_pointer_v = is_null_pointer<_Tp>::value; + +#if _GLIBCXX_USE_BUILTIN_TRAIT(__is_integral) +template <typename _Tp> + inline constexpr bool is_integral_v = __is_integral(_Tp); +#else template <typename _Tp> inline constexpr bool is_integral_v = is_integral<_Tp>::value; +#endif + template <typename _Tp> inline constexpr bool is_floating_point_v = is_floating_point<_Tp>::value; -- 2.43.0