From patchwork Thu Sep 1 19:33:40 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Wakely X-Patchwork-Id: 908 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:ecc5:0:0:0:0:0 with SMTP id s5csp399099wro; Thu, 1 Sep 2022 12:37:03 -0700 (PDT) X-Google-Smtp-Source: AA6agR64Z3v9M+y7kkt70clYWPy5/tdMRLxJ1bhL1nsVON0MJl5/+76IaLZ4++AWYFYUqL/hXinv X-Received: by 2002:a17:906:8b81:b0:733:183b:988e with SMTP id nr1-20020a1709068b8100b00733183b988emr24522102ejc.457.1662061023452; Thu, 01 Sep 2022 12:37:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662061023; cv=none; d=google.com; s=arc-20160816; b=QDtht2EXfd012W9elUDw6W3kufwQZV3J5rOAmcJDtj0Olm0Au4C2QiSzhW9aY/FR+/ PHK1E3n+Acmpogk25sCLC7jhDLldcBOm+WcdM/X+d4hSQccMC0VYrsAEZQO8xfFK/m7r 1VNBVsT9eDFFPna0oshDCwpZwjVA89jruK7qaC0BqIthSv81tzlyrdYwqOUYU0qKnlkv TYphGqrdLxidKcbFKbouJ6r9c8JB6GqX5iVniEEwH7UEAxqRxvJc6RAwS+VmoqT/5Iy+ XauC71FsZoo3bFFaKDOAfF5Lg4FHajnDAk/j8i3cZWOtQmMC7W3eooOAR3/G3J217K4O i4Ag== 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=snQgEhJm+MUXhaYYo5SM25DdDhES17mS24Qcgz9DUfM=; b=BbAtDTBbaYe0mjZTPd/0YsnxCi300KH/pppZct7cfgrpCCrTGiYfLMjcCauLcGiEnW UQalWLCVyFYlS+gkLhW3hmdwS5lvsDm4068WgG1RH7t3mvUOgabn1EYUd7KRUm/J94LU ohUxNkxKnIZ6t3JM6abzVw5ycm3P/Pxq/ln/VyMXq38y5Y6Io82Imc1hB80wubSG1qx9 BKgoYuZP8RIMDLkLpV8crq1x68z9ZaP+D0vswzTrUAs3Vj/R7H6+HiLCYBWi/CQ8eFK0 NTXWlG32q48rsPHtCIc04UaRMZJRayb5eF45a2qRbv4UsoaGJxQC4VcNAG4fXTtUFcbf Cekg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=tl8XviaS; 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 (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id nd19-20020a170907629300b007310a8a4116si115085ejc.30.2022.09.01.12.37.03 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Sep 2022 12:37:03 -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=tl8XviaS; 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 093CC3838154 for ; Thu, 1 Sep 2022 19:35:20 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 093CC3838154 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1662060920; bh=snQgEhJm+MUXhaYYo5SM25DdDhES17mS24Qcgz9DUfM=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=tl8XviaSPLlR7f7eWzhj9rmiGma3x5LSs78OnwFfwg8Nb67qpW+DLRuq0ZGpzwQ+7 gt16ydGd6A7qX8L9pwgkXledQKesmj43KVl0lSzMWpD5QF8NzttbtepwFdm91DeB6A J/A/LWpZ90oGrVhyToboGlRKmpgZzZYRNh0lj//Q= 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 C73153858289 for ; Thu, 1 Sep 2022 19:33:42 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org C73153858289 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-665-6JIG3f2OPb6-PIRPpMVpWw-1; Thu, 01 Sep 2022 15:33:41 -0400 X-MC-Unique: 6JIG3f2OPb6-PIRPpMVpWw-1 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id EA0D3185A794; Thu, 1 Sep 2022 19:33:40 +0000 (UTC) Received: from localhost (unknown [10.33.36.187]) by smtp.corp.redhat.com (Postfix) with ESMTP id ACC6F492CA2; Thu, 1 Sep 2022 19:33:40 +0000 (UTC) To: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: [committed] libstdc++: Add specializations for some variable templates Date: Thu, 1 Sep 2022 20:33:40 +0100 Message-Id: <20220901193340.352562-1-jwakely@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.85 on 10.11.54.9 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?1742797299948529595?= X-GMAIL-MSGID: =?utf-8?q?1742797299948529595?= Tested powerpc64le-linux, pushed to trunk. -- >8 -- This avoids having to instantiate a class template when we can detect the true cases easily with a partial specialization. libstdc++-v3/ChangeLog: * include/std/type_traits (is_lvalue_reference_v) (is_rvalue_reference_v, is_reference_v, is_const_v) (is_volatile_v): Define using partial specializations instead of instantiating class templates. --- libstdc++-v3/include/std/type_traits | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/libstdc++-v3/include/std/type_traits b/libstdc++-v3/include/std/type_traits index 52cca8bf3af..e4b9b59ce08 100644 --- a/libstdc++-v3/include/std/type_traits +++ b/libstdc++-v3/include/std/type_traits @@ -3153,11 +3153,13 @@ template template inline constexpr bool is_pointer_v = is_pointer<_Tp>::value; template - inline constexpr bool is_lvalue_reference_v = - is_lvalue_reference<_Tp>::value; + inline constexpr bool is_lvalue_reference_v = false; template - inline constexpr bool is_rvalue_reference_v = - is_rvalue_reference<_Tp>::value; + inline constexpr bool is_lvalue_reference_v<_Tp&> = true; +template + inline constexpr bool is_rvalue_reference_v = false; +template + inline constexpr bool is_rvalue_reference_v<_Tp&&> = true; template inline constexpr bool is_member_object_pointer_v = is_member_object_pointer<_Tp>::value; @@ -3173,7 +3175,11 @@ template template inline constexpr bool is_function_v = is_function<_Tp>::value; template - inline constexpr bool is_reference_v = is_reference<_Tp>::value; + inline constexpr bool is_reference_v = false; +template + inline constexpr bool is_reference_v<_Tp&> = true; +template + inline constexpr bool is_reference_v<_Tp&&> = true; template inline constexpr bool is_arithmetic_v = is_arithmetic<_Tp>::value; template @@ -3187,9 +3193,13 @@ template template inline constexpr bool is_member_pointer_v = is_member_pointer<_Tp>::value; template - inline constexpr bool is_const_v = is_const<_Tp>::value; + inline constexpr bool is_const_v = false; template - inline constexpr bool is_volatile_v = is_volatile<_Tp>::value; + inline constexpr bool is_const_v = true; +template + inline constexpr bool is_volatile_v = false; +template + inline constexpr bool is_volatile_v = true; template inline constexpr bool is_trivial_v = is_trivial<_Tp>::value; template