1 //===----------------------------------------------------------------------===// 2 // 3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 // See https://llvm.org/LICENSE.txt for license information. 5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 // 7 //===----------------------------------------------------------------------===// 8 9 #ifndef _LIBCPP___TYPE_TRAITS_IS_NOTHROW_CONVERTIBLE_H 10 #define _LIBCPP___TYPE_TRAITS_IS_NOTHROW_CONVERTIBLE_H 11 12 #include <__config> 13 #include <__type_traits/conjunction.h> 14 #include <__type_traits/disjunction.h> 15 #include <__type_traits/integral_constant.h> 16 #include <__type_traits/is_convertible.h> 17 #include <__type_traits/is_void.h> 18 #include <__type_traits/lazy.h> 19 #include <__utility/declval.h> 20 21 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) 22 # pragma GCC system_header 23 #endif 24 25 _LIBCPP_BEGIN_NAMESPACE_STD 26 27 #if _LIBCPP_STD_VER >= 20 28 29 template <typename _Tp> 30 void __test_noexcept(_Tp) noexcept; 31 32 template <typename _Fm, typename _To> 33 bool_constant<noexcept(std::__test_noexcept<_To>(std::declval<_Fm>()))> __is_nothrow_convertible_test(); 34 35 template <typename _Fm, typename _To> 36 struct __is_nothrow_convertible_helper : decltype(__is_nothrow_convertible_test<_Fm, _To>()) {}; 37 38 template <typename _Fm, typename _To> 39 struct is_nothrow_convertible 40 : _Or<_And<is_void<_To>, is_void<_Fm>>, 41 _Lazy<_And, is_convertible<_Fm, _To>, __is_nothrow_convertible_helper<_Fm, _To> > >::type {}; 42 43 template <typename _Fm, typename _To> 44 inline constexpr bool is_nothrow_convertible_v = is_nothrow_convertible<_Fm, _To>::value; 45 46 #endif // _LIBCPP_STD_VER >= 20 47 48 _LIBCPP_END_NAMESPACE_STD 49 50 #endif // _LIBCPP___TYPE_TRAITS_IS_NOTHROW_CONVERTIBLE_H 51