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_TRIVIALLY_DESTRUCTIBLE_H
10 #define _LIBCPP___TYPE_TRAITS_IS_TRIVIALLY_DESTRUCTIBLE_H
11 
12 #include <__config>
13 #include <__type_traits/integral_constant.h>
14 
15 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
16 #  pragma GCC system_header
17 #endif
18 
19 _LIBCPP_BEGIN_NAMESPACE_STD
20 
21 #if __has_builtin(__is_trivially_destructible)
22 
23 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_destructible
24     : public integral_constant<bool, __is_trivially_destructible(_Tp)> {};
25 
26 #elif __has_builtin(__has_trivial_destructor)
27 
28 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_destructible
29     : public integral_constant<bool, is_destructible<_Tp>::value && __has_trivial_destructor(_Tp)> {};
30 
31 #else
32 
33 template <class _Tp> struct __libcpp_trivial_destructor
34     : public integral_constant<bool, is_scalar<_Tp>::value ||
35                                      is_reference<_Tp>::value> {};
36 
37 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_destructible
38     : public __libcpp_trivial_destructor<typename remove_all_extents<_Tp>::type> {};
39 
40 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_destructible<_Tp[]>
41     : public false_type {};
42 
43 #endif // __has_builtin(__is_trivially_destructible)
44 
45 #if _LIBCPP_STD_VER > 14
46 template <class _Tp>
47 inline constexpr bool is_trivially_destructible_v = is_trivially_destructible<_Tp>::value;
48 #endif
49 
50 _LIBCPP_END_NAMESPACE_STD
51 
52 #endif // _LIBCPP___TYPE_TRAITS_IS_TRIVIALLY_DESTRUCTIBLE_H
53