From patchwork Tue Oct 4 16:46:31 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Wakely X-Patchwork-Id: 1694 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp216067wrs; Tue, 4 Oct 2022 09:48:59 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6pcyvzLe1Gmx5p9y0YypcQP3ngHq4ekodWqkyCbyqpWFi21j7wmZr4c5UFUyy4pj++Q51O X-Received: by 2002:a50:fc0a:0:b0:458:73c0:7e04 with SMTP id i10-20020a50fc0a000000b0045873c07e04mr19627183edr.270.1664902139132; Tue, 04 Oct 2022 09:48:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664902139; cv=none; d=google.com; s=arc-20160816; b=PKizyztqTGdyDrB2jvOgd1+27bBtJoQpKAXrlLsduETE3MdEtgbaO/FWyfh6bRzqFe hXJev5gxVtht0bHmKPy1KFE7F/p1dXLLnsMZ3jrzOCeAj7lggSSJrmnCNKMe81xTD9m0 Y3U+3PdjaD6GgEnZDnXbzSr1anPNcST8Q8po68SnHT7xMCwJr3626Amp2bpzScQdop21 DOBjJvqd2s7bMxvTG6ni50pWXYIMOlUZIukc9Q0iakZJiPMa782G0HYl0Hnbai62HiTh ziMNwneC+9YlsbmMSdUxZK3gJ/QK6aCyB4KzNv16ZUeWjyjn4RFDiRVrcM5vA2WXLZNS +nbQ== 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=iwkbcIqh9cwbNU5aMfD8SAZUxcj8ozUbL8e1fy19kaA=; b=DxhX6Is6pqnXjMotzQGleq6QStOBK4kpXsrQPw519aHNiOPqw64UpjJNX4oS+IZm4r 0vlyl5/wGv9tYpF6C2mRboKLoje11USUh9W6+i78k5U5mub8Bh4Qu+We43U9ACOXiSfB tP2+4jXjG0jjXESXxSa6IvZA7ql2qnZZkMSn1+Dlc6qSU65av1dlC1+eyx1KNWDLxVy0 sS2sAzVnPvy0vKj5X6xJNWVk11JJ9WHAs90P1G29xJK0x5/NSMuXBdbH5APO7oyre2MH rzuMeXn4Pqq1anrFi2//dL7pPXlNVWmzfn52/ZvBxSk1BhI+RveKzstZMMe9e3OPcxfQ Tqzg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=hGw0+Y2N; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c 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 (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id y23-20020aa7d517000000b00458ea8cbfb2si5955529edq.505.2022.10.04.09.48.58 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Oct 2022 09:48:59 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=hGw0+Y2N; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c 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 2BA5D385355A for ; Tue, 4 Oct 2022 16:47:55 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2BA5D385355A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1664902075; bh=iwkbcIqh9cwbNU5aMfD8SAZUxcj8ozUbL8e1fy19kaA=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=hGw0+Y2NZU31lM58i852vZO+pvOvHoLdXk+RBOA5l149ZLcQOCi6BXpESclYfDFL3 U5iRSycO1NfWES8v1It3w8AU68IJohbhBiL3TPASdbTkUCZ06BckTvNpkUR3JP3fOZ xRiyTbCXU3GSh9TMEoHoXHKI/k/tWpSNxan/Vng0= 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.129.124]) by sourceware.org (Postfix) with ESMTPS id 1479638582BF for ; Tue, 4 Oct 2022 16:46:42 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 1479638582BF Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-331-3RjowyyAM_OohkIhdsj0kA-1; Tue, 04 Oct 2022 12:46:38 -0400 X-MC-Unique: 3RjowyyAM_OohkIhdsj0kA-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 085D31C07820; Tue, 4 Oct 2022 16:46:32 +0000 (UTC) Received: from localhost (unknown [10.33.36.64]) by smtp.corp.redhat.com (Postfix) with ESMTP id C09CC2027063; Tue, 4 Oct 2022 16:46:31 +0000 (UTC) To: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: [committed] libstdc++: Use new built-ins __remove_cv, __remove_reference etc. Date: Tue, 4 Oct 2022 17:46:31 +0100 Message-Id: <20221004164631.558750-1-jwakely@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-12.8 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_LOW, 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 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?1745776425204338876?= X-GMAIL-MSGID: =?utf-8?q?1745776425204338876?= Tested powerpc64le-linux. Pushed to trunk. -- >8 -- libstdc++-v3/ChangeLog: * include/std/type_traits (remove_cv): Use __remove_cv built-in. (remove_reference): Use __remove_reference built-in. (remove_cvref): Use __remove_cvref built-in. Remove inheritance for fallback implementation. --- libstdc++-v3/include/std/type_traits | 33 ++++++++++++++++++++-------- 1 file changed, 24 insertions(+), 9 deletions(-) diff --git a/libstdc++-v3/include/std/type_traits b/libstdc++-v3/include/std/type_traits index a015fd95a71..b74565eb521 100644 --- a/libstdc++-v3/include/std/type_traits +++ b/libstdc++-v3/include/std/type_traits @@ -1507,6 +1507,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { typedef _Tp type; }; /// remove_cv +#if __has_builtin(__remove_cv) + template + struct remove_cv + { using type = __remove_cv(_Tp); }; +#else template struct remove_cv { using type = _Tp; }; @@ -1522,6 +1527,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION template struct remove_cv { using type = _Tp; }; +#endif /// add_const template @@ -1570,17 +1576,23 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION // Reference transformations. /// remove_reference +#if __has_builtin(__remove_reference) template struct remove_reference - { typedef _Tp type; }; + { using type = __remove_reference(_Tp); }; +#else + template + struct remove_reference + { using type = _Tp; }; template struct remove_reference<_Tp&> - { typedef _Tp type; }; + { using type = _Tp; }; template struct remove_reference<_Tp&&> - { typedef _Tp type; }; + { using type = _Tp; }; +#endif /// add_lvalue_reference template @@ -3358,20 +3370,23 @@ template */ #define __cpp_lib_remove_cvref 201711L +#if __has_builtin(__remove_cvref) template struct remove_cvref - : remove_cv<_Tp> - { }; + { using type = __remove_cvref(_Tp); }; +#else + template + struct remove_cvref + { using type = typename remove_cv<_Tp>::type; }; template struct remove_cvref<_Tp&> - : remove_cv<_Tp> - { }; + { using type = typename remove_cv<_Tp>::type; }; template struct remove_cvref<_Tp&&> - : remove_cv<_Tp> - { }; + { using type = typename remove_cv<_Tp>::type; }; +#endif template using remove_cvref_t = typename remove_cvref<_Tp>::type;