]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
libstdc++: Do not use __is_convertible unconditionally [PR113241]
authorJonathan Wakely <jwakely@redhat.com>
Fri, 5 Jan 2024 12:03:22 +0000 (12:03 +0000)
committerJonathan Wakely <jwakely@redhat.com>
Sat, 6 Jan 2024 13:39:49 +0000 (13:39 +0000)
The new __is_convertible built-in should only be used after checking
that it's supported.

libstdc++-v3/ChangeLog:

PR libstdc++/113241
* include/std/type_traits (is_convertible_v): Guard use of
built-in with preprocessor check.

(cherry picked from commit 57fa5b60bbbf8038b8a699d2bcebd2a9b2e29aa4)

libstdc++-v3/include/std/type_traits

index 2bd607a8b8ff52aba6fd205ab1af2bc4b92f78d0..2b05e3719539c6282df1af8090c8c8dbfde1abbb 100644 (file)
@@ -3359,8 +3359,13 @@ template <typename _Tp>
 #endif
 template <typename _Base, typename _Derived>
   inline constexpr bool is_base_of_v = __is_base_of(_Base, _Derived);
+#if __has_builtin(__is_convertible)
 template <typename _From, typename _To>
   inline constexpr bool is_convertible_v = __is_convertible(_From, _To);
+#else
+template <typename _From, typename _To>
+  inline constexpr bool is_convertible_v = is_convertible<_From, _To>::value;
+#endif
 template<typename _Fn, typename... _Args>
   inline constexpr bool is_invocable_v = is_invocable<_Fn, _Args...>::value;
 template<typename _Fn, typename... _Args>