From patchwork Thu Sep 1 19:33:59 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Wakely X-Patchwork-Id: 909 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:ecc5:0:0:0:0:0 with SMTP id s5csp399291wro; Thu, 1 Sep 2022 12:37:39 -0700 (PDT) X-Google-Smtp-Source: AA6agR7CXzTAusa43khPGIZebQqVIgmM+6NzCP23rJNjJ4g1g1zWds/JsHnAKO8CtxQbAMah7ADo X-Received: by 2002:a05:6402:44c:b0:445:f2f1:4add with SMTP id p12-20020a056402044c00b00445f2f14addmr30569085edw.257.1662061059045; Thu, 01 Sep 2022 12:37:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662061059; cv=none; d=google.com; s=arc-20160816; b=DkOz/0b/uYL17MM+WJRdzhAz8R1fLMpCz5Rr3iYWT0yiHfI6/Y6FDPh9evnL4Lplp2 YF0Z4Ybd+V6z15AGrQzBzIN0Ija64sYPkQKp3jxBhSYN/H0xTILfuZmpC8PLARDL6jGP Ef8MCFRgXx8lX/UoU5f8IYjn8oAaCUwDI/TtWgDdUtb/PJ55Nai+7QBesBHCv3wpiIl5 1PLX9DVDdJbUDqFupXNMy2yKC0DUV1eibqCXlM1cwnNxQuX1Hh6945YhG0b5qmejNwqZ jdsjK+sCaflWRD68K8RJaGyQqBI+dsxMTDJa4AMovCxXsZ7rgZ1O6vDIWFJvXbCeyEz9 9Pzw== 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=BFPrk94ThfysDEDJs7HAwrU0p5m6UjtJXMeenA5RFyQ=; b=kKLnVCKpBSQcfKdLGvCrKZo4zYOX9RCQwV1GuJbYmBVqQtzUivp4BXnxzcKEtaTO37 DdA5BZIJvbywxH8bepErOPTbsvWt0Tfnagfp3iKfG64ZSctZnoGH8OWcbeHwKtomuBDL Q61MUcu1xB6nCHgDN1ZY/ez2MkqAiVAbJ9J8BLLnkles8fIsFl6nfke1lHjGWiiHwgH7 esYTGHnrftegZx4kZatYjz+XvBuK52ouZ1P6A/DwYkog5N1FVQObEXpFw0AaLj1E+zWk xluvsXksAutmrEKjIy8r5J5VwBqncueoPZNO9W1G7GV8g+50SYRbe76wfZh3FuON1UxB 1Fzg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=ZGRSX2y6; 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 eb10-20020a0564020d0a00b004479eacc9acsi21096edb.222.2022.09.01.12.37.38 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Sep 2022 12:37:39 -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=ZGRSX2y6; 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 842C838286C6 for ; Thu, 1 Sep 2022 19:35:42 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 842C838286C6 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1662060942; bh=BFPrk94ThfysDEDJs7HAwrU0p5m6UjtJXMeenA5RFyQ=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=ZGRSX2y6+UeMIcjSWzCY1UoFKSQVfXUcpeeRNl3mGpVL3PS1UitpRiOgRNoiPPChs OnLtxtkWCgGWoVxSXdOGecBoo8Whq9nAKXqJFJdOS6CpJQh/BJ8nTtonxjw6KKNtV4 psqV8Jxcnw3pvY0WomzagdoEuieRx9PEZsDyuE9g= 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 346903857B97 for ; Thu, 1 Sep 2022 19:34:02 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 346903857B97 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-159-9ouZdRwlM4a12zvGLpdMew-1; Thu, 01 Sep 2022 15:34:00 -0400 X-MC-Unique: 9ouZdRwlM4a12zvGLpdMew-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 6FDB9185A7A4; Thu, 1 Sep 2022 19:34:00 +0000 (UTC) Received: from localhost (unknown [10.33.36.187]) by smtp.corp.redhat.com (Postfix) with ESMTP id 38B841410F37; Thu, 1 Sep 2022 19:34:00 +0000 (UTC) To: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: [committed] libstdc++: Remove __is_referenceable helper Date: Thu, 1 Sep 2022 20:33:59 +0100 Message-Id: <20220901193359.352625-1-jwakely@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.85 on 10.11.54.7 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-12.3 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, 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 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?1742797336918138859?= X-GMAIL-MSGID: =?utf-8?q?1742797336918138859?= Tested powerpc64le-linux, pushed to trunk. -- >8 -- We only use the __is_referenceable helper in three places now: add_pointer, add_lvalue_reference, and add_rvalue_reference. But lots of other traits depend on add_[lr]value_reference, and decay depends on add_pointer, so removing the instantiation of __is_referenceable helps compile all those other traits slightly faster. We can just use void_t to check for a referenceable type in the add_[lr]value_reference traits. Then we can specialize add_pointer for reference types, so that we don't need to use remove_reference, and then use void_t for all non-reference types to detect when we can form a pointer to the type. libstdc++-v3/ChangeLog: * include/std/type_traits (__is_referenceable): Remove. (__add_lvalue_reference_helper, __add_rvalue_reference_helper): Use __void_t instead of __is_referenceable. (__add_pointer_helper): Likewise. (add_pointer): Add partial specializations for reference types. --- libstdc++-v3/include/std/type_traits | 37 ++++++++++++---------------- 1 file changed, 16 insertions(+), 21 deletions(-) diff --git a/libstdc++-v3/include/std/type_traits b/libstdc++-v3/include/std/type_traits index 3041ac3c941..8b11f31741b 100644 --- a/libstdc++-v3/include/std/type_traits +++ b/libstdc++-v3/include/std/type_traits @@ -712,18 +712,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION // __void_t (std::void_t for C++11) template using __void_t = void; - - // Utility to detect referenceable types ([defns.referenceable]). - - template - struct __is_referenceable - : public false_type - { }; - - template - struct __is_referenceable<_Tp, __void_t<_Tp&>> - : public true_type - { }; /// @endcond // Type properties. @@ -1024,12 +1012,12 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION }; /// @cond undocumented - template::value> + template struct __add_lvalue_reference_helper { using type = _Tp; }; template - struct __add_lvalue_reference_helper<_Tp, true> + struct __add_lvalue_reference_helper<_Tp, __void_t<_Tp&>> { using type = _Tp&; }; template @@ -1046,12 +1034,12 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION }; /// @cond undocumented - template::value> + template struct __add_rvalue_reference_helper { using type = _Tp; }; template - struct __add_rvalue_reference_helper<_Tp, true> + struct __add_rvalue_reference_helper<_Tp, __void_t<_Tp&&>> { using type = _Tp&&; }; template @@ -1971,14 +1959,13 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION : public __remove_pointer_helper<_Tp, __remove_cv_t<_Tp>> { }; - template, - is_void<_Tp>>::value> + template struct __add_pointer_helper - { typedef _Tp type; }; + { using type = _Tp; }; template - struct __add_pointer_helper<_Tp, true> - { typedef typename remove_reference<_Tp>::type* type; }; + struct __add_pointer_helper<_Tp, __void_t<_Tp*>> + { using type = _Tp*; }; /// add_pointer template @@ -1986,6 +1973,14 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION : public __add_pointer_helper<_Tp> { }; + template + struct add_pointer<_Tp&> + { using type = _Tp*; }; + + template + struct add_pointer<_Tp&&> + { using type = _Tp*; }; + #if __cplusplus > 201103L /// Alias template for remove_pointer template