On Wed, 10 Jan 2024 at 19:43, Ken Matsui <kmat...@gcc.gnu.org> wrote:
>
> This patch optimizes the compilation performance of
> std::is_floating_point by dispatching to the new
> __is_floating_point built-in trait.

OK for trunk (if the new built-in is approved).


>
> libstdc++-v3/ChangeLog:
>
>         * include/std/type_traits (is_floating_point): Use
>         __is_floating_point built-in trait.
>         (is_floating_point_v): Likewise.
>
> Signed-off-by: Ken Matsui <kmat...@gcc.gnu.org>
> ---
>  libstdc++-v3/include/std/type_traits | 13 +++++++++++++
>  1 file changed, 13 insertions(+)
>
> diff --git a/libstdc++-v3/include/std/type_traits 
> b/libstdc++-v3/include/std/type_traits
> index afa281d9cc4..23ea70eca18 100644
> --- a/libstdc++-v3/include/std/type_traits
> +++ b/libstdc++-v3/include/std/type_traits
> @@ -470,6 +470,13 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
>      { };
>  #endif
>
> +#if _GLIBCXX_USE_BUILTIN_TRAIT(__is_floating_point)
> +  /// is_floating_point
> +  template<typename _Tp>
> +    struct is_floating_point
> +    : public __bool_constant<__is_floating_point(_Tp)>
> +    { };
> +#else
>    /// @cond undocumented
>    template<typename>
>      struct __is_floating_point_helper
> @@ -529,6 +536,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
>      struct is_floating_point
>      : public __is_floating_point_helper<__remove_cv_t<_Tp>>::type
>      { };
> +#endif
>
>    /// is_array
>  #if _GLIBCXX_USE_BUILTIN_TRAIT(__is_array)
> @@ -3238,8 +3246,13 @@ template <typename _Tp>
>    inline constexpr bool is_integral_v = is_integral<_Tp>::value;
>  #endif
>
> +#if _GLIBCXX_USE_BUILTIN_TRAIT(__is_floating_point)
> +template <typename _Tp>
> +  inline constexpr bool is_floating_point_v = __is_floating_point(_Tp);
> +#else
>  template <typename _Tp>
>    inline constexpr bool is_floating_point_v = is_floating_point<_Tp>::value;
> +#endif
>
>  #if _GLIBCXX_USE_BUILTIN_TRAIT(__is_array)
>  template <typename _Tp>
> --
> 2.43.0
>

Reply via email to