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_DESTRUCTIBLE_H
10 #define _LIBCPP___TYPE_TRAITS_IS_NOTHROW_DESTRUCTIBLE_H
11 
12 #include <__config>
13 #include <__type_traits/add_const.h>
14 #include <__type_traits/integral_constant.h>
15 #include <__type_traits/is_destructible.h>
16 #include <__type_traits/is_reference.h>
17 #include <__type_traits/is_scalar.h>
18 #include <__type_traits/remove_all_extents.h>
19 #include <__utility/declval.h>
20 #include <cstddef>
21 
22 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
23 #  pragma GCC system_header
24 #endif
25 
26 _LIBCPP_BEGIN_NAMESPACE_STD
27 
28 #if !defined(_LIBCPP_CXX03_LANG)
29 
30 template <bool, class _Tp> struct __libcpp_is_nothrow_destructible;
31 
32 template <class _Tp>
33 struct __libcpp_is_nothrow_destructible<false, _Tp>
34     : public false_type
35 {
36 };
37 
38 template <class _Tp>
39 struct __libcpp_is_nothrow_destructible<true, _Tp>
40     : public integral_constant<bool, noexcept(declval<_Tp>().~_Tp()) >
41 {
42 };
43 
44 template <class _Tp>
45 struct _LIBCPP_TEMPLATE_VIS is_nothrow_destructible
46     : public __libcpp_is_nothrow_destructible<is_destructible<_Tp>::value, _Tp>
47 {
48 };
49 
50 template <class _Tp, size_t _Ns>
51 struct _LIBCPP_TEMPLATE_VIS is_nothrow_destructible<_Tp[_Ns]>
52     : public is_nothrow_destructible<_Tp>
53 {
54 };
55 
56 template <class _Tp>
57 struct _LIBCPP_TEMPLATE_VIS is_nothrow_destructible<_Tp&>
58     : public true_type
59 {
60 };
61 
62 template <class _Tp>
63 struct _LIBCPP_TEMPLATE_VIS is_nothrow_destructible<_Tp&&>
64     : public true_type
65 {
66 };
67 
68 #else
69 
70 template <class _Tp> struct __libcpp_nothrow_destructor
71     : public integral_constant<bool, is_scalar<_Tp>::value ||
72                                      is_reference<_Tp>::value> {};
73 
74 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_nothrow_destructible
75     : public __libcpp_nothrow_destructor<typename remove_all_extents<_Tp>::type> {};
76 
77 template <class _Tp>
78 struct _LIBCPP_TEMPLATE_VIS is_nothrow_destructible<_Tp[]>
79     : public false_type {};
80 
81 #endif
82 
83 #if _LIBCPP_STD_VER > 14
84 template <class _Tp>
85 inline constexpr bool is_nothrow_destructible_v = is_nothrow_destructible<_Tp>::value;
86 #endif
87 
88 _LIBCPP_END_NAMESPACE_STD
89 
90 #endif // _LIBCPP___TYPE_TRAITS_IS_NOTHROW_DESTRUCTIBLE_H
91