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_ASSIGNABLE_H
10 #define _LIBCPP___TYPE_TRAITS_IS_NOTHROW_ASSIGNABLE_H
11 
12 #include <__config>
13 #include <__type_traits/add_const.h>
14 #include <__type_traits/integral_constant.h>
15 
16 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
17 #  pragma GCC system_header
18 #endif
19 
20 _LIBCPP_BEGIN_NAMESPACE_STD
21 
22 #if __has_builtin(__is_nothrow_assignable)
23 
24 template <class _Tp, class _Arg>
25 struct _LIBCPP_TEMPLATE_VIS is_nothrow_assignable
26     : public integral_constant<bool, __is_nothrow_assignable(_Tp, _Arg)> {};
27 
28 #else
29 
30 template <bool, class _Tp, class _Arg> struct __libcpp_is_nothrow_assignable;
31 
32 template <class _Tp, class _Arg>
33 struct __libcpp_is_nothrow_assignable<false, _Tp, _Arg>
34     : public false_type
35 {
36 };
37 
38 template <class _Tp, class _Arg>
39 struct __libcpp_is_nothrow_assignable<true, _Tp, _Arg>
40     : public integral_constant<bool, noexcept(declval<_Tp>() = declval<_Arg>()) >
41 {
42 };
43 
44 template <class _Tp, class _Arg>
45 struct _LIBCPP_TEMPLATE_VIS is_nothrow_assignable
46     : public __libcpp_is_nothrow_assignable<is_assignable<_Tp, _Arg>::value, _Tp, _Arg>
47 {
48 };
49 
50 #endif // __has_builtin(__is_nothrow_assignable)
51 
52 #if _LIBCPP_STD_VER > 14
53 template <class _Tp, class _Arg>
54 inline constexpr bool is_nothrow_assignable_v = is_nothrow_assignable<_Tp, _Arg>::value;
55 #endif
56 
57 _LIBCPP_END_NAMESPACE_STD
58 
59 #endif // _LIBCPP___TYPE_TRAITS_IS_NOTHROW_ASSIGNABLE_H
60