From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2181) id DB6543858C83; Mon, 26 Sep 2022 22:48:25 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org DB6543858C83 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1664232505; bh=Lhx8P+AnPW8YlxWlhPy59vLiu9g4GCz9l8cTqU1E9hw=; h=From:To:Subject:Date:From; b=dq2QTiYm0XD1+skOcJPfz0FWhdND0VOCfG0je3MAnbrjRjJy67ZsL3XftcWnh4ewe vwMefMnyqerjip4rW9GGAR8TkZGMqj723Xq3KXNUaWZyYDg6ukMzR4sQvY+jLCZNwM dioIL80BRP0ZKqOZLYe0ZDlb2NDv7tRKFFHb2RIo= MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Jonathan Wakely To: gcc-cvs@gcc.gnu.org, libstdc++-cvs@gcc.gnu.org Subject: [gcc r13-2883] libstdc++: Use new built-ins for std::is_convertible traits X-Act-Checkin: gcc X-Git-Author: Jonathan Wakely X-Git-Refname: refs/heads/master X-Git-Oldrev: 7701ea4a70a5a5c0fd977da90a30ffc4f3f87617 X-Git-Newrev: af85ad891703db220b25e7847f10d0bbec4becf4 Message-Id: <20220926224825.DB6543858C83@sourceware.org> Date: Mon, 26 Sep 2022 22:48:25 +0000 (GMT) List-Id: https://gcc.gnu.org/g:af85ad891703db220b25e7847f10d0bbec4becf4 commit r13-2883-gaf85ad891703db220b25e7847f10d0bbec4becf4 Author: Jonathan Wakely Date: Fri Sep 23 23:21:11 2022 +0100 libstdc++: Use new built-ins for std::is_convertible traits 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. Diff: --- 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