From patchwork Mon Sep 26 22:49:04 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Wakely X-Patchwork-Id: 1477 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5044:0:0:0:0:0 with SMTP id h4csp45092wrt; Mon, 26 Sep 2022 15:51:00 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7LbztlMYH2Ni0A1DLDaqu4mSrKRBrgcS1DHdsc9Ih0ndc0iotqqFOEgPxK8Sm3WZMWydOR X-Received: by 2002:a17:906:8a66:b0:781:714a:1f2a with SMTP id hy6-20020a1709068a6600b00781714a1f2amr20503127ejc.205.1664232660590; Mon, 26 Sep 2022 15:51:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664232660; cv=none; d=google.com; s=arc-20160816; b=q+nAopRP8gSoRrrrjIHGGddw6SnOGV9kHNJ2U1Vp7tw/aHMf9mIoHCpHLmMZ1BTGYQ kVv+0//ua4yz8tUbwDupIZ8c18edsN6PjiM4BmQHEBJWOV843W28cUruSpK3dQCSD+R2 Re08bKXzTVloXrJEMLMmRWfNe0MWucw+M0785yKTx/HvE32rPKduBo0f9X0CTngM61qF IFC5hweVJh6/fXN9vhUgfKFaz0uSky97h/M/HUsE2gnja02F1dlIZggaOMVUh/97h1JJ vDXCgtIQF88qh7VJSz6g7Oh14aXvVJE7k+NhOEJPTQsb7VUHj+9GMEdz5tNYzqbJSIXU E3aw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence :content-transfer-encoding:mime-version:message-id:date:subject:to :dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=Iw2dLUneYW55kBmANiTcpaE6NzyGZnIS3GltMqyoUlE=; b=VvUAKFEVsZAb1mWTcZpNEjtJj8y4PnFbhOBtL/rXMTKVFbOOywwaSeWq9qmi/h2JJd QYkZv+T1wPI/XOTTZR5FFwewXDSyM3uTC2UAm05IdiZzmV/yhv+nlbQuwDiH9OWfNh62 JqOfMWD3NZ/uHimdVoxMRbnvtbq1Ed9ygSblvMVUU/Q0vy1Cg2uU/qMbnz5lTmmjelwl dR1k7aQ+Mb8QFYyfFx9uSiw+U3vzhXzrI+QpKtR2vRj3WhuznVcxrhpSBuiVk3lypIQW H/t58hT6/E0vWypG/Iw/pS9rSWKaXlWob6I3lwd2BYbu6N42wV9d5q1jgzsieDE5PZ9H Sy1w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=XvWusOV9; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id hw9-20020a170907a0c900b0073d6ad8251asi1145824ejc.812.2022.09.26.15.51.00 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Sep 2022 15:51:00 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=XvWusOV9; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id A1ABE38582BC for ; Mon, 26 Sep 2022 22:50:25 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A1ABE38582BC DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1664232625; bh=Iw2dLUneYW55kBmANiTcpaE6NzyGZnIS3GltMqyoUlE=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=XvWusOV9AMYvcB2jItHyXKYGrXW4LnEn0SokJtdAKUWpbN0YirQDgB/CmuNoq1OlT XDriF1k+LUjJnPpePOFj8yJzxioff/heFtEbjIwpK9RhrCmCkcNHKMEnpXOTQe7TqD yVVfMGvIMl3BnnrHRtdER2ymO5Afu8jBwuujX34I= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id 24B5F3858D37 for ; Mon, 26 Sep 2022 22:49:12 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 24B5F3858D37 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-246-UiJcFLIqPiKkF3zar5UXKA-1; Mon, 26 Sep 2022 18:49:05 -0400 X-MC-Unique: UiJcFLIqPiKkF3zar5UXKA-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 2D50885A583; Mon, 26 Sep 2022 22:49:05 +0000 (UTC) Received: from localhost (unknown [10.33.36.214]) by smtp.corp.redhat.com (Postfix) with ESMTP id E92C52166B26; Mon, 26 Sep 2022 22:49:04 +0000 (UTC) To: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: [committed] libstdc++: Use new built-ins for std::is_convertible traits Date: Mon, 26 Sep 2022 23:49:04 +0100 Message-Id: <20220926224904.2235882-1-jwakely@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-12.0 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Jonathan Wakely via Gcc-patches From: Jonathan Wakely Reply-To: Jonathan Wakely Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1745074426447996083?= X-GMAIL-MSGID: =?utf-8?q?1745074426447996083?= Tested powerpc64le-linux. Pushed to trunk. -- >8 -- libstdc++-v3/ChangeLog: * include/std/type_traits (is_convertible, is_convertible_v): Define using new built-in. (is_nothrow_convertible is_nothrow_convertible_v): Likewise. --- libstdc++-v3/include/std/type_traits | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/libstdc++-v3/include/std/type_traits b/libstdc++-v3/include/std/type_traits index c5853fcad90..1ac805152d4 100644 --- a/libstdc++-v3/include/std/type_traits +++ b/libstdc++-v3/include/std/type_traits @@ -1381,6 +1381,12 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION : public integral_constant { }; +#if __has_builtin(__is_convertible) + template + struct is_convertible + : public __bool_constant<__is_convertible(_From, _To)> + { }; +#else template, is_function<_To>, is_array<_To>>::value> @@ -1416,12 +1422,28 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION struct is_convertible : public __is_convertible_helper<_From, _To>::type { }; +#endif // helper trait for unique_ptr, shared_ptr, and span template using __is_array_convertible = is_convertible<_FromElementType(*)[], _ToElementType(*)[]>; +#if __cplusplus >= 202002L +#define __cpp_lib_is_nothrow_convertible 201806L + +#if __has_builtin(__is_nothrow_convertible) + /// is_nothrow_convertible_v + template + inline constexpr bool is_nothrow_convertible_v + = __is_nothrow_convertible(_From, _To); + + /// is_nothrow_convertible + template + struct is_nothrow_convertible + : public bool_constant> + { }; +#else template, is_function<_To>, is_array<_To>>::value> @@ -1451,8 +1473,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION }; #pragma GCC diagnostic pop -#if __cplusplus > 201703L -#define __cpp_lib_is_nothrow_convertible 201806L /// is_nothrow_convertible template struct is_nothrow_convertible @@ -1463,6 +1483,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION template inline constexpr bool is_nothrow_convertible_v = is_nothrow_convertible<_From, _To>::value; +#endif #endif // C++2a // Const-volatile modifications. @@ -3265,7 +3286,7 @@ template template inline constexpr bool is_base_of_v = __is_base_of(_Base, _Derived); template - inline constexpr bool is_convertible_v = is_convertible<_From, _To>::value; + inline constexpr bool is_convertible_v = __is_convertible(_From, _To); template inline constexpr bool is_invocable_v = is_invocable<_Fn, _Args...>::value; template