On Tue, 8 Aug 2023 at 21:09, Jonathan Wakely wrote: > > > On Sat, 15 Jul 2023 at 05:57, Ken Matsui via Libstdc++ < > libstdc++@gcc.gnu.org> wrote: > >> This patch optimizes the performance of the is_arithmetic trait by >> dispatching to the new __is_arithmetic built-in trait. >> >> libstdc++-v3/ChangeLog: >> >> * include/std/type_traits (is_arithmetic): Use __is_arithmetic >> built-in trait. >> (is_arithmetic_v): Likewise. >> >> Signed-off-by: Ken Matsui >> > > OK for trunk (if the front-end changes are approved). > Oh, this is the v2 patch and there's a v4 ... but I think they're the same. > > > > >> --- >> libstdc++-v3/include/std/type_traits | 14 ++++++++++++++ >> 1 file changed, 14 insertions(+) >> >> diff --git a/libstdc++-v3/include/std/type_traits >> b/libstdc++-v3/include/std/type_traits >> index 0e7a9c9c7f3..7ebbe04c77b 100644 >> --- a/libstdc++-v3/include/std/type_traits >> +++ b/libstdc++-v3/include/std/type_traits >> @@ -655,10 +655,17 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION >> { }; >> >> /// is_arithmetic >> +#if __has_builtin(__is_arithmetic) >> + template >> + struct is_arithmetic >> + : public __bool_constant<__is_arithmetic(_Tp)> >> + { }; >> +#else >> template >> struct is_arithmetic >> : public __or_, is_floating_point<_Tp>>::type >> { }; >> +#endif >> >> /// is_fundamental >> template >> @@ -3198,8 +3205,15 @@ template >> inline constexpr bool is_reference_v<_Tp&> = true; >> template >> inline constexpr bool is_reference_v<_Tp&&> = true; >> + >> +#if __has_builtin(__is_arithmetic) >> +template >> + inline constexpr bool is_arithmetic_v = __is_arithmetic(_Tp); >> +#else >> template >> inline constexpr bool is_arithmetic_v = is_arithmetic<_Tp>::value; >> +#endif >> + >> template >> inline constexpr bool is_fundamental_v = is_fundamental<_Tp>::value; >> template >> -- >> 2.41.0 >> >>