@@ -64,11 +64,9 @@ _LIBCPP_BEGIN_NAMESPACE_STD
64
64
template <class _Tp >
65
65
struct _LIBCPP_TEMPLATE_VIS default_delete {
66
66
static_assert (!is_function<_Tp>::value, " default_delete cannot be instantiated for function types" );
67
- #ifndef _LIBCPP_CXX03_LANG
68
- _LIBCPP_HIDE_FROM_ABI constexpr default_delete () _NOEXCEPT = default;
69
- #else
70
- _LIBCPP_HIDE_FROM_ABI default_delete () {}
71
- #endif
67
+
68
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR default_delete () _NOEXCEPT = default;
69
+
72
70
template <class _Up , __enable_if_t <is_convertible<_Up*, _Tp*>::value, int > = 0 >
73
71
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 default_delete (const default_delete<_Up>&) _NOEXCEPT {}
74
72
@@ -81,34 +79,23 @@ struct _LIBCPP_TEMPLATE_VIS default_delete {
81
79
82
80
template <class _Tp >
83
81
struct _LIBCPP_TEMPLATE_VIS default_delete<_Tp[]> {
84
- private:
85
- template <class _Up >
86
- struct _EnableIfConvertible : enable_if<is_convertible<_Up (*)[], _Tp (*)[]>::value> {};
82
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR default_delete () _NOEXCEPT = default;
87
83
88
- public:
89
- #ifndef _LIBCPP_CXX03_LANG
90
- _LIBCPP_HIDE_FROM_ABI constexpr default_delete () _NOEXCEPT = default;
91
- #else
92
- _LIBCPP_HIDE_FROM_ABI default_delete () {}
93
- #endif
94
-
95
- template <class _Up >
96
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23
97
- default_delete (const default_delete<_Up[]>&, typename _EnableIfConvertible<_Up>::type* = 0 ) _NOEXCEPT {}
84
+ template <class _Up , __enable_if_t <is_convertible<_Up (*)[], _Tp (*)[]>::value, int > = 0 >
85
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 default_delete (const default_delete<_Up[]>&) _NOEXCEPT {}
98
86
99
- template <class _Up >
100
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 typename _EnableIfConvertible<_Up>::type
101
- operator ()(_Up* __ptr) const _NOEXCEPT {
87
+ template <class _Up , __enable_if_t <is_convertible<_Up (*)[], _Tp (*)[]>::value, int > = 0 >
88
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 void operator ()(_Up* __ptr) const _NOEXCEPT {
102
89
static_assert (sizeof (_Up) >= 0 , " cannot delete an incomplete type" );
103
90
delete[] __ptr;
104
91
}
105
92
};
106
93
107
94
template <class _Deleter >
108
- struct __is_default_deleter : false_type {} ;
95
+ inline const bool __is_default_deleter_v = false ;
109
96
110
97
template <class _Tp >
111
- struct __is_default_deleter <default_delete<_Tp> > : true_type {} ;
98
+ inline const bool __is_default_deleter_v <default_delete<_Tp> > = true ;
112
99
113
100
template <class _Deleter >
114
101
struct __unique_ptr_deleter_sfinae {
@@ -355,7 +342,7 @@ struct __unique_ptr_array_bounds_stateless {
355
342
356
343
template <class _Deleter ,
357
344
class _Tp ,
358
- __enable_if_t <__is_default_deleter <_Deleter>::value && __has_array_cookie<_Tp>::value, int > = 0 >
345
+ __enable_if_t <__is_default_deleter_v <_Deleter> && __has_array_cookie<_Tp>::value, int > = 0 >
359
346
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool __in_bounds (_Tp* __ptr, size_t __index) const {
360
347
// In constant expressions, we can't check the array cookie so we just pretend that the index
361
348
// is in-bounds. The compiler catches invalid accesses anyway.
@@ -367,7 +354,7 @@ struct __unique_ptr_array_bounds_stateless {
367
354
368
355
template <class _Deleter ,
369
356
class _Tp ,
370
- __enable_if_t <!__is_default_deleter <_Deleter>::value || !__has_array_cookie<_Tp>::value, int > = 0 >
357
+ __enable_if_t <!__is_default_deleter_v <_Deleter> || !__has_array_cookie<_Tp>::value, int > = 0 >
371
358
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool __in_bounds (_Tp*, size_t ) const {
372
359
return true ; // If we don't have an array cookie, we assume the access is in-bounds
373
360
}
@@ -385,7 +372,7 @@ struct __unique_ptr_array_bounds_stored {
385
372
// Use the array cookie if there's one
386
373
template <class _Deleter ,
387
374
class _Tp ,
388
- __enable_if_t <__is_default_deleter <_Deleter>::value && __has_array_cookie<_Tp>::value, int > = 0 >
375
+ __enable_if_t <__is_default_deleter_v <_Deleter> && __has_array_cookie<_Tp>::value, int > = 0 >
389
376
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool __in_bounds (_Tp* __ptr, size_t __index) const {
390
377
if (__libcpp_is_constant_evaluated ())
391
378
return true ;
@@ -396,7 +383,7 @@ struct __unique_ptr_array_bounds_stored {
396
383
// Otherwise, fall back on the stored size (if any)
397
384
template <class _Deleter ,
398
385
class _Tp ,
399
- __enable_if_t <!__is_default_deleter <_Deleter>::value || !__has_array_cookie<_Tp>::value, int > = 0 >
386
+ __enable_if_t <!__is_default_deleter_v <_Deleter> || !__has_array_cookie<_Tp>::value, int > = 0 >
400
387
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool __in_bounds (_Tp*, size_t __index) const {
401
388
return __index < __size_;
402
389
}
0 commit comments