aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDimitry Andric <dimitry@andric.com>2026-01-05 19:55:12 +0000
committerDimitry Andric <dim@FreeBSD.org>2026-04-25 14:14:20 +0000
commit035396ceda495f456ca570fb715b04a7fc3b25c2 (patch)
treef374cb631556c14eac0fc4100188e027738a7fab
parenta114ece3e6158f49088b0704b4afef07040d83f3 (diff)
libcxx-compat: revert llvmorg-21-init-10154-ge43e8ec7afbd:
[libc++] Remove dead implementation of is_nothrow_convertible and merge the remaining code into is_convertible.h (#137717) We can use the `__is_nothrow_convertible` builtin unconditionally now, which makes the implementation very simple, so there isn't much of a need to keep a separate header around. This is part of making libc++ 21 build with clang 18. PR: 292067 MFC after: 1 month
-rw-r--r--contrib/llvm-project/libcxx/include/__type_traits/is_convertible.h26
1 files changed, 26 insertions, 0 deletions
diff --git a/contrib/llvm-project/libcxx/include/__type_traits/is_convertible.h b/contrib/llvm-project/libcxx/include/__type_traits/is_convertible.h
index f0a859f9cc16..56f26ffaec71 100644
--- a/contrib/llvm-project/libcxx/include/__type_traits/is_convertible.h
+++ b/contrib/llvm-project/libcxx/include/__type_traits/is_convertible.h
@@ -10,6 +10,9 @@
#define _LIBCPP___TYPE_TRAITS_IS_CONVERTIBLE_H
#include <__config>
+#include <__type_traits/conjunction.h>
+#include <__type_traits/disjunction.h>
+#include <__type_traits/lazy.h>
#include <__type_traits/integral_constant.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
@@ -28,12 +31,35 @@ _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_convertible_v = __is_convert
#if _LIBCPP_STD_VER >= 20
+# if __has_builtin(__is_nothrow_convertible)
+
template <class _Tp, class _Up>
struct _LIBCPP_NO_SPECIALIZATIONS is_nothrow_convertible : bool_constant<__is_nothrow_convertible(_Tp, _Up)> {};
template <class _Tp, class _Up>
_LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_nothrow_convertible_v = __is_nothrow_convertible(_Tp, _Up);
+# else // __has_builtin(__is_nothrow_convertible)
+
+template <typename _Tp>
+void __test_noexcept(_Tp) noexcept;
+
+template <typename _Fm, typename _To>
+bool_constant<noexcept(std::__test_noexcept<_To>(std::declval<_Fm>()))> __is_nothrow_convertible_test();
+
+template <typename _Fm, typename _To>
+struct __is_nothrow_convertible_helper : decltype(std::__is_nothrow_convertible_test<_Fm, _To>()) {};
+
+template <typename _Fm, typename _To>
+struct is_nothrow_convertible
+ : _Or<_And<is_void<_To>, is_void<_Fm>>,
+ _Lazy<_And, is_convertible<_Fm, _To>, __is_nothrow_convertible_helper<_Fm, _To> > >::type {};
+
+template <typename _Fm, typename _To>
+inline constexpr bool is_nothrow_convertible_v = is_nothrow_convertible<_Fm, _To>::value;
+
+# endif // __has_builtin(__is_nothrow_convertible)
+
#endif // _LIBCPP_STD_VER >= 20
_LIBCPP_END_NAMESPACE_STD