From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-oi1-x232.google.com (mail-oi1-x232.google.com [IPv6:2607:f8b0:4864:20::232]) by sourceware.org (Postfix) with ESMTPS id B1AD53830B5F for ; Fri, 1 Sep 2023 13:00:55 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org B1AD53830B5F 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-oi1-x232.google.com with SMTP id 5614622812f47-3a7aedc57ffso1259638b6e.2 for ; Fri, 01 Sep 2023 06:00:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cs.washington.edu; s=goo201206; t=1693573255; x=1694178055; darn=gcc.gnu.org; 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=UDeidQxryAlU6s8zob24JtfCFCPxur/6x2m2hv9/IlM=; b=j8cr0r9K3Ci0fSYFqrsmE/6iLNPBEI5SUvhFARMvvg7jYWt1+x9CN0u6YMy/oZQBCG +R5axj8xZZ7yCP2p9kTnvNBKhLEUyQin8+PF/ZBXLFf4JsgrsHuL6YF4ktUzp4tG1yXQ AixKSUrHLAgcKSC4CfR519aGKOzlSp7Ks0HM4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693573255; x=1694178055; 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=UDeidQxryAlU6s8zob24JtfCFCPxur/6x2m2hv9/IlM=; b=MKFFBrfER1Jqmo/ZTqWPN7I0XOiyso5gfjYiuC159xJHoXIICpDUXzEe/vmzUCyk83 10Zf99Pqh0W14+Uv+kgjgZ1HW0F+I3U5vrRLVkziTDfA7dRueI20B9IPrOC72GAmtUXs 1g7yS+pIINXmREaLJC+/zLaX+va/d03x7IcUrmXHQ9H87miWG3/q9LjbliDSbpxe+FQ8 aag4W7VSX8oSB48QqQt0hqW3enihBx1EnQ1yxiymL/4gAI+LoxLegqQvf2EESuKRsy1h /izaHCbqbvFbS6HD5MeB9a0+73qVlWrcjTDZ/qiFMXJFt1uEYo1u1oNhYVDK20uHOFdZ L4IQ== X-Gm-Message-State: AOJu0Yy8XVpOfNR5F0z4tRKlVYfAyRuaOEjOfK3tMUhxoYQTQyco2hWe DKgtZxtln7QyTnQZJTg9Pe4iMqDne82xRMiboXRT9w== X-Google-Smtp-Source: AGHT+IGnk27+r+0NY7bPyFz2zJjJyx2D2VVm2B+A3rWBDTCsoR0hlaH+0EhoTeJYwfR6zdqvtGk7Nm9VsOHZ2A7Qgeo= X-Received: by 2002:a05:6358:4323:b0:133:b42:69ca with SMTP id r35-20020a056358432300b001330b4269camr2541585rwc.18.1693573254856; Fri, 01 Sep 2023 06:00:54 -0700 (PDT) MIME-Version: 1.0 References: <20230713031901.18162-2-kmatsui@gcc.gnu.org> <20230713204823.22303-1-kmatsui@gcc.gnu.org> <20230713204823.22303-2-kmatsui@gcc.gnu.org> In-Reply-To: <20230713204823.22303-2-kmatsui@gcc.gnu.org> From: Ken Matsui Date: Fri, 1 Sep 2023 06:00:00 -0700 Message-ID: Subject: [PING][PATCH v6 2/2] libstdc++: Use new built-in trait __is_pointer To: Jonathan Wakely Cc: gcc-patches , "libstdc++" , Ken Matsui Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-10.3 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 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: Ping for the use of __is_pointer built-in. Sincerely, Ken Matsui On Thu, Jul 13, 2023 at 1:49=E2=80=AFPM Ken Matsui wr= ote: > > This patch lets libstdc++ use new built-in trait __is_pointer. > > libstdc++-v3/ChangeLog: > > * include/bits/cpp_type_traits.h (__is_ptr): Use __is_pointer > built-in trait. > * include/std/type_traits (is_pointer): Likewise. Optimize its > implementation. > (is_pointer_v): Likewise. > > Co-authored-by: Jonathan Wakely > Signed-off-by: Ken Matsui > --- > libstdc++-v3/include/bits/cpp_type_traits.h | 8 ++++ > libstdc++-v3/include/std/type_traits | 44 +++++++++++++++++---- > 2 files changed, 44 insertions(+), 8 deletions(-) > > diff --git a/libstdc++-v3/include/bits/cpp_type_traits.h b/libstdc++-v3/i= nclude/bits/cpp_type_traits.h > index 3711e4be526..4da1e7c407c 100644 > --- a/libstdc++-v3/include/bits/cpp_type_traits.h > +++ b/libstdc++-v3/include/bits/cpp_type_traits.h > @@ -363,6 +363,13 @@ __INT_N(__GLIBCXX_TYPE_INT_N_3) > // > // Pointer types > // > +#if __has_builtin(__is_pointer) > + template > + struct __is_ptr : __truth_type<__is_pointer(_Tp)> > + { > + enum { __value =3D __is_pointer(_Tp) }; > + }; > +#else > template > struct __is_ptr > { > @@ -376,6 +383,7 @@ __INT_N(__GLIBCXX_TYPE_INT_N_3) > enum { __value =3D 1 }; > typedef __true_type __type; > }; > +#endif > > // > // An arithmetic type is an integer type or a floating point type > diff --git a/libstdc++-v3/include/std/type_traits b/libstdc++-v3/include/= std/type_traits > index 0e7a9c9c7f3..16b2f6de536 100644 > --- a/libstdc++-v3/include/std/type_traits > +++ b/libstdc++-v3/include/std/type_traits > @@ -515,19 +515,33 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION > struct is_array<_Tp[]> > : public true_type { }; > > - template > - struct __is_pointer_helper > + /// is_pointer > +#if __has_builtin(__is_pointer) > + template > + struct is_pointer > + : public __bool_constant<__is_pointer(_Tp)> > + { }; > +#else > + template > + struct is_pointer > : public false_type { }; > > template > - struct __is_pointer_helper<_Tp*> > + struct is_pointer<_Tp*> > : public true_type { }; > > - /// is_pointer > template > - struct is_pointer > - : public __is_pointer_helper<__remove_cv_t<_Tp>>::type > - { }; > + struct is_pointer<_Tp* const> > + : public true_type { }; > + > + template > + struct is_pointer<_Tp* volatile> > + : public true_type { }; > + > + template > + struct is_pointer<_Tp* const volatile> > + : public true_type { }; > +#endif > > /// is_lvalue_reference > template > @@ -3168,8 +3182,22 @@ template > template > inline constexpr bool is_array_v<_Tp[_Num]> =3D true; > > +#if __has_builtin(__is_pointer) > +template > + inline constexpr bool is_pointer_v =3D __is_pointer(_Tp); > +#else > template > - inline constexpr bool is_pointer_v =3D is_pointer<_Tp>::value; > + inline constexpr bool is_pointer_v =3D false; > +template > + inline constexpr bool is_pointer_v<_Tp*> =3D true; > +template > + inline constexpr bool is_pointer_v<_Tp* const> =3D true; > +template > + inline constexpr bool is_pointer_v<_Tp* volatile> =3D true; > +template > + inline constexpr bool is_pointer_v<_Tp* const volatile> =3D true; > +#endif > + > template > inline constexpr bool is_lvalue_reference_v =3D false; > template > -- > 2.41.0 >