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 89F1F3858404 for ; Mon, 26 Sep 2022 22:49:07 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 89F1F3858404 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1664232547; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=Iw2dLUneYW55kBmANiTcpaE6NzyGZnIS3GltMqyoUlE=; b=Ir9bPCEXGe5svjWpwRADijATskx0VfroW/Tqh/gqYhWssZckvPJ4EE2POnoYpFQHrYhzaV MmnIZn5+TkeDnoP7cWml5hCAAoUKjGw4zAjiHNE15houqp0Ofc1eZVdBjJaUHrDy0G+BSH TLKioZm4MU/D+JqUuXBf+6CUxEWxlqY= 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-246-UiJcFLIqPiKkF3zar5UXKA-1; Mon, 26 Sep 2022 18:49:05 -0400 X-MC-Unique: UiJcFLIqPiKkF3zar5UXKA-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 2D50885A583; Mon, 26 Sep 2022 22:49:05 +0000 (UTC) Received: from localhost (unknown [10.33.36.214]) by smtp.corp.redhat.com (Postfix) with ESMTP id E92C52166B26; Mon, 26 Sep 2022 22:49:04 +0000 (UTC) From: Jonathan Wakely To: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: [committed] libstdc++: Use new built-ins for std::is_convertible traits Date: Mon, 26 Sep 2022 23:49:04 +0100 Message-Id: <20220926224904.2235882-1-jwakely@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-12.0 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 autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: Tested powerpc64le-linux. Pushed to trunk. -- >8 -- libstdc++-v3/ChangeLog: * include/std/type_traits (is_convertible, is_convertible_v): Define using new built-in. (is_nothrow_convertible is_nothrow_convertible_v): Likewise. --- libstdc++-v3/include/std/type_traits | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/libstdc++-v3/include/std/type_traits b/libstdc++-v3/include/std/type_traits index c5853fcad90..1ac805152d4 100644 --- a/libstdc++-v3/include/std/type_traits +++ b/libstdc++-v3/include/std/type_traits @@ -1381,6 +1381,12 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION : public integral_constant { }; +#if __has_builtin(__is_convertible) + template + struct is_convertible + : public __bool_constant<__is_convertible(_From, _To)> + { }; +#else template, is_function<_To>, is_array<_To>>::value> @@ -1416,12 +1422,28 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION struct is_convertible : public __is_convertible_helper<_From, _To>::type { }; +#endif // helper trait for unique_ptr, shared_ptr, and span template using __is_array_convertible = is_convertible<_FromElementType(*)[], _ToElementType(*)[]>; +#if __cplusplus >= 202002L +#define __cpp_lib_is_nothrow_convertible 201806L + +#if __has_builtin(__is_nothrow_convertible) + /// is_nothrow_convertible_v + template + inline constexpr bool is_nothrow_convertible_v + = __is_nothrow_convertible(_From, _To); + + /// is_nothrow_convertible + template + struct is_nothrow_convertible + : public bool_constant> + { }; +#else template, is_function<_To>, is_array<_To>>::value> @@ -1451,8 +1473,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION }; #pragma GCC diagnostic pop -#if __cplusplus > 201703L -#define __cpp_lib_is_nothrow_convertible 201806L /// is_nothrow_convertible template struct is_nothrow_convertible @@ -1463,6 +1483,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION template inline constexpr bool is_nothrow_convertible_v = is_nothrow_convertible<_From, _To>::value; +#endif #endif // C++2a // Const-volatile modifications. @@ -3265,7 +3286,7 @@ template template inline constexpr bool is_base_of_v = __is_base_of(_Base, _Derived); template - inline constexpr bool is_convertible_v = is_convertible<_From, _To>::value; + inline constexpr bool is_convertible_v = __is_convertible(_From, _To); template inline constexpr bool is_invocable_v = is_invocable<_Fn, _Args...>::value; template -- 2.37.3