mirror of
https://git.FreeBSD.org/src.git
synced 2026-06-02 11:24:32 +00:00
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
(cherry picked from commit 035396ceda)
This commit is contained in:
committed by
Dimitry Andric
parent
a2694ead33
commit
bdeece2037
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user