On Sat, 22 Jul 2023 at 14:51, François Dumont via Libstdc++ < libstdc++@gcc.gnu.org> wrote: > > On 18/07/2023 08:27, Ken Matsui via Libstdc++ wrote: > > This patch implements built-in trait for std::is_arithmetic. > > > > gcc/cp/ChangeLog: > > > > * cp-trait.def: Define __is_arithmetic. > > * constraint.cc (diagnose_trait_expr): Handle CPTK_IS_ARITHMETIC. > > * semantics.cc (trait_expr_value): Likewise. > > (finish_trait_expr): Likewise. > > > > gcc/testsuite/ChangeLog: > > > > * g++.dg/ext/has-builtin-1.C: Test existence of __is_arithmetic. > > * g++.dg/ext/is_arithmetic.C: New test. > > * g++.dg/tm/pr46567.C (__is_arithmetic): Rename to ... > > (__is_arith): ... this. > > * g++.dg/torture/pr57107.C: Likewise. > > > > libstdc++-v3/ChangeLog: > > > > * include/bits/cpp_type_traits.h (__is_arithmetic): Rename to ... > > (__is_arith): ... this. > > * include/c_global/cmath: Use __is_arith instead. > > * include/c_std/cmath: Likewise. > > * include/tr1/cmath: Likewise. > > > > Signed-off-by: Ken Matsui > > --- > > gcc/cp/constraint.cc | 3 ++ > > gcc/cp/cp-trait.def | 1 + > > gcc/cp/semantics.cc | 4 ++ > > gcc/testsuite/g++.dg/ext/has-builtin-1.C | 3 ++ > > gcc/testsuite/g++.dg/ext/is_arithmetic.C | 33 ++++++++++++++ > > gcc/testsuite/g++.dg/tm/pr46567.C | 6 +-- > > gcc/testsuite/g++.dg/torture/pr57107.C | 4 +- > > libstdc++-v3/include/bits/cpp_type_traits.h | 4 +- > > libstdc++-v3/include/c_global/cmath | 48 ++++++++++----------- > > libstdc++-v3/include/c_std/cmath | 24 +++++------ > > libstdc++-v3/include/tr1/cmath | 24 +++++------ > > 11 files changed, 99 insertions(+), 55 deletions(-) > > create mode 100644 gcc/testsuite/g++.dg/ext/is_arithmetic.C > > [...] > diff --git a/libstdc++-v3/include/bits/cpp_type_traits.h > b/libstdc++-v3/include/bits/cpp_type_traits.h > > index 4312f32a4e0..d00d1ea8d75 100644 > > --- a/libstdc++-v3/include/bits/cpp_type_traits.h > > +++ b/libstdc++-v3/include/bits/cpp_type_traits.h > > @@ -381,7 +381,7 @@ __INT_N(__GLIBCXX_TYPE_INT_N_3) > > // An arithmetic type is an integer type or a floating point type > > // > > template > > - struct __is_arithmetic > > + struct __is_arith > > : public __traitor<__is_integer<_Tp>, __is_floating<_Tp> > > > { }; > > 'ptr' is a well known alias of 'pointer', I wouldn't say the same for > 'arith' and 'arithmetic'. > > But wait for a native-english feedback to change anything. > > I think it's clear enough. This is only an internal trait anyway, not part of a public API. Since all uses are with the __enable_if trait, we could add this helper and get rid of __is_arithmetic completely: template::__value || __is_floating<_Tp>::__value> struct __enable_if_arithmetic { }; template struct __enable_if_arithmetic<_Tp, _Res, true> { typedef _Res __type; }; And similarly for a two-argument __enable_if_both_arithmetic helper. But we can consider doing that later, I think __is_arith is fine for now. The libstdc++ parts of this patch are OK (but wait for approval for the compiler changes from a G++ maintainer before pushing).