From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 8D02B3858D3C for ; Thu, 1 Sep 2022 19:33:36 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 8D02B3858D3C 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) From: Jonathan Wakely 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 Content-Type: text/plain Content-Transfer-Encoding: 8bit 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=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: libstdc++@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libstdc++ mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 01 Sep 2022 19:33:37 -0000 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 -- 2.37.2