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