|
14 | 14 | #include <__config> |
15 | 15 | #include <__memory/addressof.h> |
16 | 16 | #include <__new/placement_new_delete.h> |
17 | | -#include <__type_traits/enable_if.h> |
18 | 17 | #include <__type_traits/is_array.h> |
19 | 18 | #include <__utility/declval.h> |
20 | 19 | #include <__utility/forward.h> |
@@ -55,35 +54,25 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Tp* __construct_at(_Tp* __l |
55 | 54 | // The internal functions are available regardless of the language version (with the exception of the `__destroy_at` |
56 | 55 | // taking an array). |
57 | 56 |
|
58 | | -template <class _Tp, __enable_if_t<!is_array<_Tp>::value, int> = 0> |
| 57 | +template <class _Tp> |
59 | 58 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __destroy_at(_Tp* __loc) { |
60 | 59 | _LIBCPP_ASSERT_NON_NULL(__loc != nullptr, "null pointer given to destroy_at"); |
61 | | - __loc->~_Tp(); |
62 | | -} |
63 | | - |
64 | 60 | #if _LIBCPP_STD_VER >= 20 |
65 | | -template <class _Tp, __enable_if_t<is_array<_Tp>::value, int> = 0> |
66 | | -_LIBCPP_HIDE_FROM_ABI constexpr void __destroy_at(_Tp* __loc) { |
67 | | - _LIBCPP_ASSERT_NON_NULL(__loc != nullptr, "null pointer given to destroy_at"); |
68 | | - for (auto&& __val : *__loc) |
69 | | - std::__destroy_at(std::addressof(__val)); |
70 | | -} |
| 61 | + if constexpr (is_array_v<_Tp>) { |
| 62 | + for (auto&& __val : *__loc) |
| 63 | + std::__destroy_at(std::addressof(__val)); |
| 64 | + } else |
71 | 65 | #endif |
| 66 | + { |
| 67 | + __loc->~_Tp(); |
| 68 | + } |
| 69 | +} |
72 | 70 |
|
73 | 71 | #if _LIBCPP_STD_VER >= 17 |
74 | | - |
75 | | -template <class _Tp, enable_if_t<!is_array_v<_Tp>, int> = 0> |
| 72 | +template <class _Tp> |
76 | 73 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void destroy_at(_Tp* _LIBCPP_DIAGNOSE_NULLPTR __loc) { |
77 | 74 | std::__destroy_at(__loc); |
78 | 75 | } |
79 | | - |
80 | | -# if _LIBCPP_STD_VER >= 20 |
81 | | -template <class _Tp, enable_if_t<is_array_v<_Tp>, int> = 0> |
82 | | -_LIBCPP_HIDE_FROM_ABI constexpr void destroy_at(_Tp* _LIBCPP_DIAGNOSE_NULLPTR __loc) { |
83 | | - std::__destroy_at(__loc); |
84 | | -} |
85 | | -# endif |
86 | | - |
87 | 76 | #endif // _LIBCPP_STD_VER >= 17 |
88 | 77 |
|
89 | 78 | _LIBCPP_END_NAMESPACE_STD |
|
0 commit comments