From patchwork Thu Sep 1 19:33:33 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Wakely X-Patchwork-Id: 906 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:ecc5:0:0:0:0:0 with SMTP id s5csp398549wro; Thu, 1 Sep 2022 12:35:16 -0700 (PDT) X-Google-Smtp-Source: AA6agR7rhepkK/BL8PNdIY77VwZTamCEqjdbVqbwAKtzAMuyDq6g1KvvNAXwexfEZJPuXSCKUUXp X-Received: by 2002:a17:907:6d03:b0:741:9b9d:ad8b with SMTP id sa3-20020a1709076d0300b007419b9dad8bmr13617659ejc.197.1662060916457; Thu, 01 Sep 2022 12:35:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662060916; cv=none; d=google.com; s=arc-20160816; b=GljPTgeprNC35Rz1cY1Pp+NdtulrkiZU7levb4JrhL6e6eJWuKAE1iBpixc0fK+zkr xO1Hr7a2LZpauBaxQ++icO2pFp0OmsqAbn414iAb16ifbH8gIxoYbZqtqy2vlH5P0EIq Z73ZZqgkCPW0eZsYA+Xtsfib7WHJ1mVGubkz4L7SSkpLTD6TBOM0ckLpkOzjRRjt2Qxx 4jGrs9ZziiKOF907tSrjoURcvJgLw+lFm5XSvZXTI8Fm9VDtwp7dCLM1v7tpo6ORYB1z zHxFHQ3YGLf/pC+LUWZ2r5iNzzaEmtONnq/7MJRt4a5Nzb53D1SyHyTQSzS0beV/o7UR d/Wg== 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=gQZeb/cKAJdltsPdjuTxWQRsZh72uzVvq1b2gm0CPdI=; b=R2wMjczFPxDWb74aivB/+94mP4vLiflfMqsKuZxIaPmv0jgw0CeVt4abeQBIX6exn/ UcudgbAssRLh40M5SIb8uceF/e4i+M5BAC6g8ZThog19vDa+2ZFTUx+kTktCmoy+CdKL A83I4BfT3KVlO96QzksiRd8Jvpq+b6c/dEOC0VPUbnY4XP/PlhzFZmyABd4+CwR7YW1y hC65SeaI3HHIs/2RTdvnPD8GUooKTM4rwV0OaN5Pl5sk8AEVo0B5DFhtXQSp82WadpWu mKZgtqlGyBuusJHGaSJiS8GFAGnaMZUauCCJ+SPgzXHVW3bbHDDk/kVJwEdfDv6GI4Ia Rh1g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=vHsV73D+; 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 b7-20020a170906490700b0072e6774827asi34973ejq.915.2022.09.01.12.35.16 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Sep 2022 12:35:16 -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=vHsV73D+; 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 B56AD3856278 for ; Thu, 1 Sep 2022 19:34:21 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B56AD3856278 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1662060861; bh=gQZeb/cKAJdltsPdjuTxWQRsZh72uzVvq1b2gm0CPdI=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=vHsV73D+72joJHoqqu4YR6JMa+seOQKFyT/zFiXbSFBq06FuX81/jjw4RfXfwmSWJ KOk+iw2Y2jtrtZ08QfT8J2JRTh9D5yMKJNjN+ZEH8NhIFrfTs9DnXKAAjGqlKWBTXa jaSqMUuuGfUTNT6ldsKLqNsDzfIsHVHzo65/X/xo= 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 25AD63858D3C for ; Thu, 1 Sep 2022 19:33:38 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 25AD63858D3C 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-674-Gg4IyWUIO2u5hVLfQx9BQA-1; Thu, 01 Sep 2022 15:33:35 -0400 X-MC-Unique: Gg4IyWUIO2u5hVLfQx9BQA-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id ABBEE101A56D; Thu, 1 Sep 2022 19:33:34 +0000 (UTC) Received: from localhost (unknown [10.33.36.187]) by smtp.corp.redhat.com (Postfix) with ESMTP id 737CA18ECC; Thu, 1 Sep 2022 19:33:34 +0000 (UTC) To: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: [committed] libstdc++: Use built-ins for some variable templates Date: Thu, 1 Sep 2022 20:33:33 +0100 Message-Id: <20220901193333.348123-1-jwakely@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-11.9 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, T_SCC_BODY_TEXT_LINE 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?1742797187776616791?= X-GMAIL-MSGID: =?utf-8?q?1742797187776616791?= Tested powerpc64le-linux, pushed to trunk. -- >8 -- This avoids having to instantiate a class template that just uses the same built-in anyway. None of the corresponding class templates have any type-completeness static assertions, so we're not losing any diagnostics by using the built-ins directly. libstdc++-v3/ChangeLog: * include/std/type_traits (is_enum_v, is_class_v, is_union_v) (is_empty_v, is_polymoprhic_v, is_abstract_v, is_final_v) (is_base_of_v, is_aggregate_v): Use built-in directly instead of instantiating class template. --- libstdc++-v3/include/std/type_traits | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/libstdc++-v3/include/std/type_traits b/libstdc++-v3/include/std/type_traits index 5b8314f24fd..52cca8bf3af 100644 --- a/libstdc++-v3/include/std/type_traits +++ b/libstdc++-v3/include/std/type_traits @@ -3165,11 +3165,11 @@ template inline constexpr bool is_member_function_pointer_v = is_member_function_pointer<_Tp>::value; template - inline constexpr bool is_enum_v = is_enum<_Tp>::value; + inline constexpr bool is_enum_v = __is_enum(_Tp); template - inline constexpr bool is_union_v = is_union<_Tp>::value; + inline constexpr bool is_union_v = __is_union(_Tp); template - inline constexpr bool is_class_v = is_class<_Tp>::value; + inline constexpr bool is_class_v = __is_class(_Tp); template inline constexpr bool is_function_v = is_function<_Tp>::value; template @@ -3206,14 +3206,14 @@ template _GLIBCXX17_DEPRECATED inline constexpr bool is_literal_type_v = is_literal_type<_Tp>::value; #pragma GCC diagnostic pop - template - inline constexpr bool is_empty_v = is_empty<_Tp>::value; template - inline constexpr bool is_polymorphic_v = is_polymorphic<_Tp>::value; + inline constexpr bool is_empty_v = __is_empty(_Tp); template - inline constexpr bool is_abstract_v = is_abstract<_Tp>::value; + inline constexpr bool is_polymorphic_v = __is_polymorphic(_Tp); template - inline constexpr bool is_final_v = is_final<_Tp>::value; + inline constexpr bool is_abstract_v = __is_abstract(_Tp); +template + inline constexpr bool is_final_v = __is_final(_Tp); template inline constexpr bool is_signed_v = is_signed<_Tp>::value; template @@ -3318,7 +3318,7 @@ template inline constexpr bool is_same_v = std::is_same<_Tp, _Up>::value; #endif template - inline constexpr bool is_base_of_v = is_base_of<_Base, _Derived>::value; + inline constexpr bool is_base_of_v = __is_base_of(_Base, _Derived); template inline constexpr bool is_convertible_v = is_convertible<_From, _To>::value; template @@ -3356,16 +3356,19 @@ template #ifdef _GLIBCXX_HAVE_BUILTIN_IS_AGGREGATE # define __cpp_lib_is_aggregate 201703L - /// is_aggregate + /// is_aggregate - true if the type is an aggregate. /// @since C++17 template struct is_aggregate : bool_constant<__is_aggregate(remove_cv_t<_Tp>)> { }; - /// @ingroup variable_templates + /** is_aggregate_v - true if the type is an aggregate. + * @ingroup variable_templates + * @since C++17 + */ template - inline constexpr bool is_aggregate_v = is_aggregate<_Tp>::value; + inline constexpr bool is_aggregate_v = __is_aggregate(remove_cv_t<_Tp>); #endif #endif // C++17