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 > 17
28 
29 template <typename _Tp>
30 static void __test_noexcept(_Tp) noexcept;
31 
32 template<typename _Fm, typename _To>
33 static bool_constant<noexcept(_VSTD::__test_noexcept<_To>(std::declval<_Fm>()))>
34 __is_nothrow_convertible_test();
35 
36 template <typename _Fm, typename _To>
37 struct __is_nothrow_convertible_helper: decltype(__is_nothrow_convertible_test<_Fm, _To>())
38 { };
39 
40 template <typename _Fm, typename _To>
41 struct is_nothrow_convertible : _Or<
42     _And<is_void<_To>, is_void<_Fm>>,
43     _Lazy<_And, is_convertible<_Fm, _To>, __is_nothrow_convertible_helper<_Fm, _To>>
44 >::type { };
45 
46 template <typename _Fm, typename _To>
47 inline constexpr bool is_nothrow_convertible_v = is_nothrow_convertible<_Fm, _To>::value;
48 
49 #endif // _LIBCPP_STD_VER > 17
50 
51 _LIBCPP_END_NAMESPACE_STD
52 
53 #endif // _LIBCPP___TYPE_TRAITS_IS_NOTHROW_CONVERTIBLE_H
54