From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-vs1-xe33.google.com (mail-vs1-xe33.google.com [IPv6:2607:f8b0:4864:20::e33]) by sourceware.org (Postfix) with ESMTPS id 6B2C93858C1F for ; Thu, 13 Jul 2023 02:56:47 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 6B2C93858C1F Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=cs.washington.edu Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=cs.washington.edu Received: by mail-vs1-xe33.google.com with SMTP id ada2fe7eead31-44387d40adaso157971137.0 for ; Wed, 12 Jul 2023 19:56:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cs.washington.edu; s=goo201206; t=1689217007; x=1691809007; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=0MOYEgMYzSNsVba8MiJwN7Ek14pqzIRfuHmYg9fXv9o=; b=YM/zTAYpWrshhww4Lt29HYmt7SsiQwA1QJn2vIN+tfaIaxz67ih3iP0Ohx2hnQlEtL MOuvrPOSPp3rbs3bbOiYvLu8/J1hj8EWuz73XC5fma+TdPgybgTyZwHYBB5GQqms7BAA NIYG+O9s8s6gtB0A0DXX2htSdspSJPKFK/Y3U= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689217007; x=1691809007; h=content-transfer-encoding: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=0MOYEgMYzSNsVba8MiJwN7Ek14pqzIRfuHmYg9fXv9o=; b=d4JzM5e6Lsf+zNS8kc9ALEE2HnfDj40ynB6yIElDNf3Uuri11KHRaRtGOT/aqQCOiK FipApE3ZKLzMsV0Jc+vesDZOD9bREOJiZIJWAXhz9w9hg7eb9oLO8vtr+XJpNLEpcGGa L6eRIwz/iKC6YK3s0LAocjnTmsrVVgaGTXMWxGHL8GHFfXzM0tE1maoI9fqcNnyV5ww7 FQKh8EUq/R6XL+nU9mRN6rNq46tN1npBvuEyCtpcIaiKS+HEmQCl3V6cw/SyAO3Oi+j5 YYWLQZgQi7xeGawbC5fBZ2zp6BbcTf6MfgcBm8AYi/0JZxL9S2A7RTUTCaR67zv8gQfR 4h1Q== X-Gm-Message-State: ABy/qLbvrlZC3m1MkAnwqtdXy4A1bZ0Lvk1dix3j6XnLAXGggpZPzr2U Px/w/tUA98Ld1GAgNRo+/NTVm2ddyN4KiETK7YtkAw== X-Google-Smtp-Source: APBJJlGIjg2lZIH1W4c0Flmiy7t+34zppI1T58vq53uf+BxEw3vtiADT679mH1K9FO8Ylv+VbCRsaRybZ+8U6EuZOdc= X-Received: by 2002:a67:ed01:0:b0:443:681b:c8ca with SMTP id l1-20020a67ed01000000b00443681bc8camr177660vsp.10.1689217006948; Wed, 12 Jul 2023 19:56:46 -0700 (PDT) MIME-Version: 1.0 References: <20230708051137.63707-1-kmatsui@gcc.gnu.org> <20230713023731.15571-1-kmatsui@gcc.gnu.org> <20230713023731.15571-3-kmatsui@gcc.gnu.org> In-Reply-To: <20230713023731.15571-3-kmatsui@gcc.gnu.org> From: Ken Matsui Date: Wed, 12 Jul 2023 19:56:31 -0700 Message-ID: Subject: Re: [PATCH v10 2/5] libstdc++: Use new built-in trait __is_reference for std::is_reference To: Ken Matsui Cc: gcc-patches@gcc.gnu.org, libstdc++@gcc.gnu.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-10.1 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE 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: Hi, Here is the benchmark result for is_reference: https://github.com/ken-matsui/gcc-benches/blob/main/is_reference.md#wed-jul= -12-074702-pm-pdt-2023 Time: -8.15593% Peak Memory Usage: -4.48408% Total Memory Usage: -8.03783% Sincerely, Ken Matsui On Wed, Jul 12, 2023 at 7:39=E2=80=AFPM Ken Matsui wr= ote: > > This patch gets std::is_reference to dispatch to new built-in trait > __is_reference. > > libstdc++-v3/ChangeLog: > > * include/std/type_traits (is_reference): Use __is_reference buil= t-in > trait. > (is_reference_v): Likewise. > > Signed-off-by: Ken Matsui > --- > 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..2a14df7e5f9 100644 > --- a/libstdc++-v3/include/std/type_traits > +++ b/libstdc++-v3/include/std/type_traits > @@ -639,6 +639,12 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION > // Composite type categories. > > /// is_reference > +#if __has_builtin(__is_reference) > + template > + struct is_reference > + : public __bool_constant<__is_reference(_Tp)> > + { }; > +#else > template > struct is_reference > : public false_type > @@ -653,6 +659,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION > struct is_reference<_Tp&&> > : public true_type > { }; > +#endif > > /// is_arithmetic > template > @@ -3192,12 +3199,19 @@ template > inline constexpr bool is_class_v =3D __is_class(_Tp); > template > inline constexpr bool is_function_v =3D is_function<_Tp>::value; > + > +#if __has_builtin(__is_reference) > +template > + inline constexpr bool is_reference_v =3D __is_reference(_Tp); > +#else > template > inline constexpr bool is_reference_v =3D false; > template > inline constexpr bool is_reference_v<_Tp&> =3D true; > template > inline constexpr bool is_reference_v<_Tp&&> =3D true; > +#endif > + > template > inline constexpr bool is_arithmetic_v =3D is_arithmetic<_Tp>::value; > template > -- > 2.41.0 >