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> 30 struct __libcpp_is_nothrow_destructible; 31 32 template <class _Tp> 33 struct __libcpp_is_nothrow_destructible<false, _Tp> : public false_type {}; 34 35 template <class _Tp> 36 struct __libcpp_is_nothrow_destructible<true, _Tp> 37 : public integral_constant<bool, noexcept(std::declval<_Tp>().~_Tp()) > {}; 38 39 template <class _Tp> 40 struct _LIBCPP_TEMPLATE_VIS is_nothrow_destructible 41 : public __libcpp_is_nothrow_destructible<is_destructible<_Tp>::value, _Tp> {}; 42 43 template <class _Tp, size_t _Ns> 44 struct _LIBCPP_TEMPLATE_VIS is_nothrow_destructible<_Tp[_Ns]> : public is_nothrow_destructible<_Tp> {}; 45 46 template <class _Tp> 47 struct _LIBCPP_TEMPLATE_VIS is_nothrow_destructible<_Tp&> : public true_type {}; 48 49 template <class _Tp> 50 struct _LIBCPP_TEMPLATE_VIS is_nothrow_destructible<_Tp&&> : public true_type {}; 51 52 #else 53 54 template <class _Tp> 55 struct __libcpp_nothrow_destructor : public integral_constant<bool, is_scalar<_Tp>::value || is_reference<_Tp>::value> { 56 }; 57 58 template <class _Tp> 59 struct _LIBCPP_TEMPLATE_VIS is_nothrow_destructible : public __libcpp_nothrow_destructor<__remove_all_extents_t<_Tp> > { 60 }; 61 62 template <class _Tp> 63 struct _LIBCPP_TEMPLATE_VIS is_nothrow_destructible<_Tp[]> : public false_type {}; 64 65 #endif 66 67 #if _LIBCPP_STD_VER >= 17 68 template <class _Tp> 69 inline constexpr bool is_nothrow_destructible_v = is_nothrow_destructible<_Tp>::value; 70 #endif 71 72 _LIBCPP_END_NAMESPACE_STD 73 74 #endif // _LIBCPP___TYPE_TRAITS_IS_NOTHROW_DESTRUCTIBLE_H 75