From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id BFD303858028 for ; Tue, 8 Aug 2023 20:05:02 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org BFD303858028 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1691525102; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=jNVDrMPjLwiMFoOs2VrOuGqf/7M+2nBCcfA5tXuwLvQ=; b=fzmETyEqTJZAZm/g75zq6if9N9Bpju7D3ar70c/SEEdbTuVJdbziyXapbPVUydI+ehZo/2 JKBKOmyWKLGpOavbrobenRvZn7HmcoF8O5k6U7wi6/cxLKWNKtWTZ94LcwCS5DxF61Bwj6 npT9d2armtm/xvSo3fT7Xjrg7Wy6cOI= Received: from mail-lj1-f200.google.com (mail-lj1-f200.google.com [209.85.208.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-241-DK7Cf2wcMqyFdSDJmZBvxw-1; Tue, 08 Aug 2023 16:05:00 -0400 X-MC-Unique: DK7Cf2wcMqyFdSDJmZBvxw-1 Received: by mail-lj1-f200.google.com with SMTP id 38308e7fff4ca-2b9ba3d6191so58807431fa.2 for ; Tue, 08 Aug 2023 13:05:00 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691525099; x=1692129899; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=jNVDrMPjLwiMFoOs2VrOuGqf/7M+2nBCcfA5tXuwLvQ=; b=ShcHad2Pkb2QHDrQRRl28o+VAcesR0pJvgAtPXFd0yr9sv6kvMi1JUueJ8anv1xnNo 1yAxgzvgH5S3ahbCrgG5cG4xbhK1pmYSH3uBLFS6Rbh8CUbeE+hDfcIcQJQCPpyVfxBV KWBgk6C3HSAOaNdCAfMjXfFPfFH5BNL4f2PpL+3XLb3HI2k9T/Gsr18M0k8VRbLhEZNk GdwUKANe2ybmYgr8Tto1ssA1EXMI20encHMwxbathecCPuS0qUL4FwGDFiy8LauvKvls 8/+c1EtB6p3B4TGIGAweoLTr2/pwI32gutzT2dwFGnFGEcwXbExuuTzc8a6MSUmS7Lz0 tiBQ== X-Gm-Message-State: AOJu0Yzmv+L99tMqthNvvVlypm/Is1p1lZxBWIrxBiTLxmSyAe//okOL 7Vy7pDJmlh25CVG50a5dKnJkEIdlVHZ018emaviSGOYNfSR59nkcTp0lZDnV6AaASChsjRibrUe a7IKFLG0cZ4EKXymojcet3CGao+dY538= X-Received: by 2002:a2e:904c:0:b0:2b9:e053:7a07 with SMTP id n12-20020a2e904c000000b002b9e0537a07mr363325ljg.45.1691525099109; Tue, 08 Aug 2023 13:04:59 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFPXapsLbBEfR1YAOC99xqFbagusFupNSolAw/v03ABbBBbG8q7lIs1n6ATzCRRJ9zonBKy1Bi3hnOBHYAQhDI= X-Received: by 2002:a2e:904c:0:b0:2b9:e053:7a07 with SMTP id n12-20020a2e904c000000b002b9e0537a07mr363317ljg.45.1691525098781; Tue, 08 Aug 2023 13:04:58 -0700 (PDT) MIME-Version: 1.0 References: <20230715045519.50684-1-kmatsui@gcc.gnu.org> <20230718062745.29470-1-kmatsui@gcc.gnu.org> <18bd2387-fb96-6ddd-db17-39d3450bd888@gmail.com> In-Reply-To: <18bd2387-fb96-6ddd-db17-39d3450bd888@gmail.com> From: Jonathan Wakely Date: Tue, 8 Aug 2023 21:04:47 +0100 Message-ID: Subject: Re: [PATCH v3 1/3] c++, libstdc++: Implement __is_arithmetic built-in trait To: =?UTF-8?Q?Fran=C3=A7ois_Dumont?= Cc: Ken Matsui , gcc-patches@gcc.gnu.org, libstdc++@gcc.gnu.org X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: multipart/alternative; boundary="000000000000a450c606026ee0c4" X-Spam-Status: No, score=-12.2 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,HTML_MESSAGE,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: --000000000000a450c606026ee0c4 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Sat, 22 Jul 2023 at 14:51, Fran=C3=A7ois 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). --000000000000a450c606026ee0c4--