aboutsummaryrefslogtreecommitdiff
path: root/contrib/llvm-project/libcxx/include/__memory/unique_ptr.h
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/llvm-project/libcxx/include/__memory/unique_ptr.h')
-rw-r--r--contrib/llvm-project/libcxx/include/__memory/unique_ptr.h373
1 files changed, 143 insertions, 230 deletions
diff --git a/contrib/llvm-project/libcxx/include/__memory/unique_ptr.h b/contrib/llvm-project/libcxx/include/__memory/unique_ptr.h
index 32e4942a834c..7bf5e3c5e4e6 100644
--- a/contrib/llvm-project/libcxx/include/__memory/unique_ptr.h
+++ b/contrib/llvm-project/libcxx/include/__memory/unique_ptr.h
@@ -51,16 +51,14 @@ _LIBCPP_BEGIN_NAMESPACE_STD
template <class _Tp>
struct _LIBCPP_TEMPLATE_VIS default_delete {
- static_assert(!is_function<_Tp>::value,
- "default_delete cannot be instantiated for function types");
+ static_assert(!is_function<_Tp>::value, "default_delete cannot be instantiated for function types");
#ifndef _LIBCPP_CXX03_LANG
_LIBCPP_HIDE_FROM_ABI constexpr default_delete() _NOEXCEPT = default;
#else
_LIBCPP_HIDE_FROM_ABI default_delete() {}
#endif
template <class _Up, __enable_if_t<is_convertible<_Up*, _Tp*>::value, int> = 0>
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 default_delete(
- const default_delete<_Up>&) _NOEXCEPT {}
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 default_delete(const default_delete<_Up>&) _NOEXCEPT {}
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 void operator()(_Tp* __ptr) const _NOEXCEPT {
static_assert(sizeof(_Tp) >= 0, "cannot delete an incomplete type");
@@ -73,8 +71,7 @@ template <class _Tp>
struct _LIBCPP_TEMPLATE_VIS default_delete<_Tp[]> {
private:
template <class _Up>
- struct _EnableIfConvertible
- : enable_if<is_convertible<_Up(*)[], _Tp(*)[]>::value> {};
+ struct _EnableIfConvertible : enable_if<is_convertible<_Up (*)[], _Tp (*)[]>::value> {};
public:
#ifndef _LIBCPP_CXX03_LANG
@@ -130,65 +127,52 @@ public:
typedef _Dp deleter_type;
typedef _LIBCPP_NODEBUG typename __pointer<_Tp, deleter_type>::type pointer;
- static_assert(!is_rvalue_reference<deleter_type>::value,
- "the specified deleter type cannot be an rvalue reference");
+ static_assert(!is_rvalue_reference<deleter_type>::value, "the specified deleter type cannot be an rvalue reference");
private:
__compressed_pair<pointer, deleter_type> __ptr_;
- struct __nat { int __for_bool_; };
+ struct __nat {
+ int __for_bool_;
+ };
typedef _LIBCPP_NODEBUG __unique_ptr_deleter_sfinae<_Dp> _DeleterSFINAE;
template <bool _Dummy>
- using _LValRefType _LIBCPP_NODEBUG =
- typename __dependent_type<_DeleterSFINAE, _Dummy>::__lval_ref_type;
+ using _LValRefType _LIBCPP_NODEBUG = typename __dependent_type<_DeleterSFINAE, _Dummy>::__lval_ref_type;
template <bool _Dummy>
- using _GoodRValRefType _LIBCPP_NODEBUG =
- typename __dependent_type<_DeleterSFINAE, _Dummy>::__good_rval_ref_type;
+ using _GoodRValRefType _LIBCPP_NODEBUG = typename __dependent_type<_DeleterSFINAE, _Dummy>::__good_rval_ref_type;
template <bool _Dummy>
- using _BadRValRefType _LIBCPP_NODEBUG =
- typename __dependent_type<_DeleterSFINAE, _Dummy>::__bad_rval_ref_type;
+ using _BadRValRefType _LIBCPP_NODEBUG = typename __dependent_type<_DeleterSFINAE, _Dummy>::__bad_rval_ref_type;
- template <bool _Dummy, class _Deleter = typename __dependent_type<
- __type_identity<deleter_type>, _Dummy>::type>
+ template <bool _Dummy, class _Deleter = typename __dependent_type< __type_identity<deleter_type>, _Dummy>::type>
using _EnableIfDeleterDefaultConstructible _LIBCPP_NODEBUG =
- __enable_if_t<is_default_constructible<_Deleter>::value &&
- !is_pointer<_Deleter>::value>;
+ __enable_if_t<is_default_constructible<_Deleter>::value && !is_pointer<_Deleter>::value>;
template <class _ArgType>
- using _EnableIfDeleterConstructible _LIBCPP_NODEBUG =
- __enable_if_t<is_constructible<deleter_type, _ArgType>::value>;
+ using _EnableIfDeleterConstructible _LIBCPP_NODEBUG = __enable_if_t<is_constructible<deleter_type, _ArgType>::value>;
template <class _UPtr, class _Up>
- using _EnableIfMoveConvertible _LIBCPP_NODEBUG = __enable_if_t<
- is_convertible<typename _UPtr::pointer, pointer>::value &&
- !is_array<_Up>::value
- >;
+ using _EnableIfMoveConvertible _LIBCPP_NODEBUG =
+ __enable_if_t< is_convertible<typename _UPtr::pointer, pointer>::value && !is_array<_Up>::value >;
template <class _UDel>
- using _EnableIfDeleterConvertible _LIBCPP_NODEBUG = __enable_if_t<
- (is_reference<_Dp>::value && is_same<_Dp, _UDel>::value) ||
- (!is_reference<_Dp>::value && is_convertible<_UDel, _Dp>::value)
- >;
+ using _EnableIfDeleterConvertible _LIBCPP_NODEBUG =
+ __enable_if_t< (is_reference<_Dp>::value && is_same<_Dp, _UDel>::value) ||
+ (!is_reference<_Dp>::value && is_convertible<_UDel, _Dp>::value) >;
template <class _UDel>
- using _EnableIfDeleterAssignable = __enable_if_t<
- is_assignable<_Dp&, _UDel&&>::value
- >;
+ using _EnableIfDeleterAssignable = __enable_if_t< is_assignable<_Dp&, _UDel&&>::value >;
public:
- template <bool _Dummy = true,
- class = _EnableIfDeleterDefaultConstructible<_Dummy> >
- _LIBCPP_HIDE_FROM_ABI
- _LIBCPP_CONSTEXPR unique_ptr() _NOEXCEPT : __ptr_(__value_init_tag(), __value_init_tag()) {}
+ template <bool _Dummy = true, class = _EnableIfDeleterDefaultConstructible<_Dummy> >
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR unique_ptr() _NOEXCEPT : __ptr_(__value_init_tag(), __value_init_tag()) {}
- template <bool _Dummy = true,
- class = _EnableIfDeleterDefaultConstructible<_Dummy> >
- _LIBCPP_HIDE_FROM_ABI
- _LIBCPP_CONSTEXPR unique_ptr(nullptr_t) _NOEXCEPT : __ptr_(__value_init_tag(), __value_init_tag()) {}
+ template <bool _Dummy = true, class = _EnableIfDeleterDefaultConstructible<_Dummy> >
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR unique_ptr(nullptr_t) _NOEXCEPT
+ : __ptr_(__value_init_tag(), __value_init_tag()) {}
template <bool _Dummy = true, class = _EnableIfDeleterDefaultConstructible<_Dummy> >
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 explicit unique_ptr(pointer __p) _NOEXCEPT
@@ -199,16 +183,13 @@ public:
: __ptr_(__p, __d) {}
template <bool _Dummy = true, class = _EnableIfDeleterConstructible<_GoodRValRefType<_Dummy> > >
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23
- unique_ptr(pointer __p, _GoodRValRefType<_Dummy> __d) _NOEXCEPT : __ptr_(__p, std::move(__d)) {
- static_assert(!is_reference<deleter_type>::value,
- "rvalue deleter bound to reference");
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unique_ptr(pointer __p, _GoodRValRefType<_Dummy> __d) _NOEXCEPT
+ : __ptr_(__p, std::move(__d)) {
+ static_assert(!is_reference<deleter_type>::value, "rvalue deleter bound to reference");
}
- template <bool _Dummy = true,
- class = _EnableIfDeleterConstructible<_BadRValRefType<_Dummy> > >
- _LIBCPP_HIDE_FROM_ABI
- unique_ptr(pointer __p, _BadRValRefType<_Dummy> __d) = delete;
+ template <bool _Dummy = true, class = _EnableIfDeleterConstructible<_BadRValRefType<_Dummy> > >
+ _LIBCPP_HIDE_FROM_ABI unique_ptr(pointer __p, _BadRValRefType<_Dummy> __d) = delete;
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unique_ptr(unique_ptr&& __u) _NOEXCEPT
: __ptr_(__u.release(), std::forward<deleter_type>(__u.get_deleter())) {}
@@ -221,11 +202,9 @@ public:
: __ptr_(__u.release(), std::forward<_Ep>(__u.get_deleter())) {}
#if _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_AUTO_PTR)
- template <class _Up, __enable_if_t<is_convertible<_Up*, _Tp*>::value &&
- is_same<_Dp, default_delete<_Tp> >::value, int> = 0>
- _LIBCPP_HIDE_FROM_ABI
- unique_ptr(auto_ptr<_Up>&& __p) _NOEXCEPT
- : __ptr_(__p.release(), __value_init_tag()) {}
+ template <class _Up,
+ __enable_if_t<is_convertible<_Up*, _Tp*>::value && is_same<_Dp, default_delete<_Tp> >::value, int> = 0>
+ _LIBCPP_HIDE_FROM_ABI unique_ptr(auto_ptr<_Up>&& __p) _NOEXCEPT : __ptr_(__p.release(), __value_init_tag()) {}
#endif
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unique_ptr& operator=(unique_ptr&& __u) _NOEXCEPT {
@@ -245,18 +224,16 @@ public:
}
#if _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_AUTO_PTR)
- template <class _Up, __enable_if_t<is_convertible<_Up*, _Tp*>::value &&
- is_same<_Dp, default_delete<_Tp> >::value, int> = 0>
- _LIBCPP_HIDE_FROM_ABI
- unique_ptr&
- operator=(auto_ptr<_Up> __p) {
+ template <class _Up,
+ __enable_if_t<is_convertible<_Up*, _Tp*>::value && is_same<_Dp, default_delete<_Tp> >::value, int> = 0>
+ _LIBCPP_HIDE_FROM_ABI unique_ptr& operator=(auto_ptr<_Up> __p) {
reset(__p.release());
return *this;
}
#endif
#ifdef _LIBCPP_CXX03_LANG
- unique_ptr(unique_ptr const&) = delete;
+ unique_ptr(unique_ptr const&) = delete;
unique_ptr& operator=(unique_ptr const&) = delete;
#endif
@@ -270,13 +247,9 @@ public:
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 __add_lvalue_reference_t<_Tp> operator*() const {
return *__ptr_.first();
}
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 pointer operator->() const _NOEXCEPT {
- return __ptr_.first();
- }
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 pointer operator->() const _NOEXCEPT { return __ptr_.first(); }
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 pointer get() const _NOEXCEPT { return __ptr_.first(); }
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 deleter_type& get_deleter() _NOEXCEPT {
- return __ptr_.second();
- }
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 deleter_type& get_deleter() _NOEXCEPT { return __ptr_.second(); }
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 const deleter_type& get_deleter() const _NOEXCEPT {
return __ptr_.second();
}
@@ -285,24 +258,21 @@ public:
}
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 pointer release() _NOEXCEPT {
- pointer __t = __ptr_.first();
+ pointer __t = __ptr_.first();
__ptr_.first() = pointer();
return __t;
}
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 void reset(pointer __p = pointer()) _NOEXCEPT {
- pointer __tmp = __ptr_.first();
+ pointer __tmp = __ptr_.first();
__ptr_.first() = __p;
if (__tmp)
__ptr_.second()(__tmp);
}
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 void swap(unique_ptr& __u) _NOEXCEPT {
- __ptr_.swap(__u.__ptr_);
- }
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 void swap(unique_ptr& __u) _NOEXCEPT { __ptr_.swap(__u.__ptr_); }
};
-
template <class _Tp, class _Dp>
class _LIBCPP_UNIQUE_PTR_TRIVIAL_ABI _LIBCPP_TEMPLATE_VIS unique_ptr<_Tp[], _Dp> {
public:
@@ -319,71 +289,52 @@ private:
template <class _FromElem>
struct _CheckArrayPointerConversion<_FromElem*>
: integral_constant<bool,
- is_same<_FromElem*, pointer>::value ||
- (is_same<pointer, element_type*>::value &&
- is_convertible<_FromElem(*)[], element_type(*)[]>::value)
- >
- {};
+ is_same<_FromElem*, pointer>::value ||
+ (is_same<pointer, element_type*>::value &&
+ is_convertible<_FromElem (*)[], element_type (*)[]>::value) > {};
typedef __unique_ptr_deleter_sfinae<_Dp> _DeleterSFINAE;
template <bool _Dummy>
- using _LValRefType _LIBCPP_NODEBUG =
- typename __dependent_type<_DeleterSFINAE, _Dummy>::__lval_ref_type;
+ using _LValRefType _LIBCPP_NODEBUG = typename __dependent_type<_DeleterSFINAE, _Dummy>::__lval_ref_type;
template <bool _Dummy>
- using _GoodRValRefType _LIBCPP_NODEBUG =
- typename __dependent_type<_DeleterSFINAE, _Dummy>::__good_rval_ref_type;
+ using _GoodRValRefType _LIBCPP_NODEBUG = typename __dependent_type<_DeleterSFINAE, _Dummy>::__good_rval_ref_type;
template <bool _Dummy>
- using _BadRValRefType _LIBCPP_NODEBUG =
- typename __dependent_type<_DeleterSFINAE, _Dummy>::__bad_rval_ref_type;
+ using _BadRValRefType _LIBCPP_NODEBUG = typename __dependent_type<_DeleterSFINAE, _Dummy>::__bad_rval_ref_type;
- template <bool _Dummy, class _Deleter = typename __dependent_type<
- __type_identity<deleter_type>, _Dummy>::type>
+ template <bool _Dummy, class _Deleter = typename __dependent_type< __type_identity<deleter_type>, _Dummy>::type>
using _EnableIfDeleterDefaultConstructible _LIBCPP_NODEBUG =
- __enable_if_t<is_default_constructible<_Deleter>::value &&
- !is_pointer<_Deleter>::value>;
+ __enable_if_t<is_default_constructible<_Deleter>::value && !is_pointer<_Deleter>::value>;
template <class _ArgType>
- using _EnableIfDeleterConstructible _LIBCPP_NODEBUG =
- __enable_if_t<is_constructible<deleter_type, _ArgType>::value>;
+ using _EnableIfDeleterConstructible _LIBCPP_NODEBUG = __enable_if_t<is_constructible<deleter_type, _ArgType>::value>;
template <class _Pp>
- using _EnableIfPointerConvertible _LIBCPP_NODEBUG = __enable_if_t<
- _CheckArrayPointerConversion<_Pp>::value
- >;
-
- template <class _UPtr, class _Up,
- class _ElemT = typename _UPtr::element_type>
- using _EnableIfMoveConvertible _LIBCPP_NODEBUG = __enable_if_t<
- is_array<_Up>::value &&
- is_same<pointer, element_type*>::value &&
- is_same<typename _UPtr::pointer, _ElemT*>::value &&
- is_convertible<_ElemT(*)[], element_type(*)[]>::value
- >;
+ using _EnableIfPointerConvertible _LIBCPP_NODEBUG = __enable_if_t< _CheckArrayPointerConversion<_Pp>::value >;
+
+ template <class _UPtr, class _Up, class _ElemT = typename _UPtr::element_type>
+ using _EnableIfMoveConvertible _LIBCPP_NODEBUG =
+ __enable_if_t< is_array<_Up>::value && is_same<pointer, element_type*>::value &&
+ is_same<typename _UPtr::pointer, _ElemT*>::value &&
+ is_convertible<_ElemT (*)[], element_type (*)[]>::value >;
template <class _UDel>
- using _EnableIfDeleterConvertible _LIBCPP_NODEBUG = __enable_if_t<
- (is_reference<_Dp>::value && is_same<_Dp, _UDel>::value) ||
- (!is_reference<_Dp>::value && is_convertible<_UDel, _Dp>::value)
- >;
+ using _EnableIfDeleterConvertible _LIBCPP_NODEBUG =
+ __enable_if_t< (is_reference<_Dp>::value && is_same<_Dp, _UDel>::value) ||
+ (!is_reference<_Dp>::value && is_convertible<_UDel, _Dp>::value) >;
template <class _UDel>
- using _EnableIfDeleterAssignable _LIBCPP_NODEBUG = __enable_if_t<
- is_assignable<_Dp&, _UDel&&>::value
- >;
+ using _EnableIfDeleterAssignable _LIBCPP_NODEBUG = __enable_if_t< is_assignable<_Dp&, _UDel&&>::value >;
public:
- template <bool _Dummy = true,
- class = _EnableIfDeleterDefaultConstructible<_Dummy> >
- _LIBCPP_HIDE_FROM_ABI
- _LIBCPP_CONSTEXPR unique_ptr() _NOEXCEPT : __ptr_(__value_init_tag(), __value_init_tag()) {}
+ template <bool _Dummy = true, class = _EnableIfDeleterDefaultConstructible<_Dummy> >
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR unique_ptr() _NOEXCEPT : __ptr_(__value_init_tag(), __value_init_tag()) {}
- template <bool _Dummy = true,
- class = _EnableIfDeleterDefaultConstructible<_Dummy> >
- _LIBCPP_HIDE_FROM_ABI
- _LIBCPP_CONSTEXPR unique_ptr(nullptr_t) _NOEXCEPT : __ptr_(__value_init_tag(), __value_init_tag()) {}
+ template <bool _Dummy = true, class = _EnableIfDeleterDefaultConstructible<_Dummy> >
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR unique_ptr(nullptr_t) _NOEXCEPT
+ : __ptr_(__value_init_tag(), __value_init_tag()) {}
template <class _Pp,
bool _Dummy = true,
@@ -409,22 +360,20 @@ public:
class = _EnableIfPointerConvertible<_Pp> >
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unique_ptr(_Pp __p, _GoodRValRefType<_Dummy> __d) _NOEXCEPT
: __ptr_(__p, std::move(__d)) {
- static_assert(!is_reference<deleter_type>::value,
- "rvalue deleter bound to reference");
+ static_assert(!is_reference<deleter_type>::value, "rvalue deleter bound to reference");
}
template <bool _Dummy = true, class = _EnableIfDeleterConstructible<_GoodRValRefType<_Dummy> > >
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unique_ptr(nullptr_t, _GoodRValRefType<_Dummy> __d) _NOEXCEPT
: __ptr_(nullptr, std::move(__d)) {
- static_assert(!is_reference<deleter_type>::value,
- "rvalue deleter bound to reference");
+ static_assert(!is_reference<deleter_type>::value, "rvalue deleter bound to reference");
}
- template <class _Pp, bool _Dummy = true,
- class = _EnableIfDeleterConstructible<_BadRValRefType<_Dummy> >,
- class = _EnableIfPointerConvertible<_Pp> >
- _LIBCPP_HIDE_FROM_ABI
- unique_ptr(_Pp __p, _BadRValRefType<_Dummy> __d) = delete;
+ template <class _Pp,
+ bool _Dummy = true,
+ class = _EnableIfDeleterConstructible<_BadRValRefType<_Dummy> >,
+ class = _EnableIfPointerConvertible<_Pp> >
+ _LIBCPP_HIDE_FROM_ABI unique_ptr(_Pp __p, _BadRValRefType<_Dummy> __d) = delete;
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unique_ptr(unique_ptr&& __u) _NOEXCEPT
: __ptr_(__u.release(), std::forward<deleter_type>(__u.get_deleter())) {}
@@ -453,9 +402,10 @@ public:
}
#ifdef _LIBCPP_CXX03_LANG
- unique_ptr(unique_ptr const&) = delete;
+ unique_ptr(unique_ptr const&) = delete;
unique_ptr& operator=(unique_ptr const&) = delete;
#endif
+
public:
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 ~unique_ptr() { reset(); }
@@ -464,15 +414,12 @@ public:
return *this;
}
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 __add_lvalue_reference_t<_Tp>
- operator[](size_t __i) const {
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 __add_lvalue_reference_t<_Tp> operator[](size_t __i) const {
return __ptr_.first()[__i];
}
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 pointer get() const _NOEXCEPT { return __ptr_.first(); }
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 deleter_type& get_deleter() _NOEXCEPT {
- return __ptr_.second();
- }
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 deleter_type& get_deleter() _NOEXCEPT { return __ptr_.second(); }
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 const deleter_type& get_deleter() const _NOEXCEPT {
return __ptr_.second();
@@ -482,36 +429,32 @@ public:
}
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 pointer release() _NOEXCEPT {
- pointer __t = __ptr_.first();
+ pointer __t = __ptr_.first();
__ptr_.first() = pointer();
return __t;
}
template <class _Pp, __enable_if_t<_CheckArrayPointerConversion<_Pp>::value, int> = 0>
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23
- void reset(_Pp __p) _NOEXCEPT {
- pointer __tmp = __ptr_.first();
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 void reset(_Pp __p) _NOEXCEPT {
+ pointer __tmp = __ptr_.first();
__ptr_.first() = __p;
if (__tmp)
__ptr_.second()(__tmp);
}
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 void reset(nullptr_t = nullptr) _NOEXCEPT {
- pointer __tmp = __ptr_.first();
+ pointer __tmp = __ptr_.first();
__ptr_.first() = nullptr;
if (__tmp)
__ptr_.second()(__tmp);
}
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 void swap(unique_ptr& __u) _NOEXCEPT {
- __ptr_.swap(__u.__ptr_);
- }
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 void swap(unique_ptr& __u) _NOEXCEPT { __ptr_.swap(__u.__ptr_); }
};
template <class _Tp, class _Dp, __enable_if_t<__is_swappable<_Dp>::value, int> = 0>
-inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23
- void
- swap(unique_ptr<_Tp, _Dp>& __x, unique_ptr<_Tp, _Dp>& __y) _NOEXCEPT {
+inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 void
+swap(unique_ptr<_Tp, _Dp>& __x, unique_ptr<_Tp, _Dp>& __y) _NOEXCEPT {
__x.swap(__y);
}
@@ -523,47 +466,41 @@ operator==(const unique_ptr<_T1, _D1>& __x, const unique_ptr<_T2, _D2>& __y) {
#if _LIBCPP_STD_VER <= 17
template <class _T1, class _D1, class _T2, class _D2>
-inline _LIBCPP_HIDE_FROM_ABI
-bool
-operator!=(const unique_ptr<_T1, _D1>& __x, const unique_ptr<_T2, _D2>& __y) {return !(__x == __y);}
+inline _LIBCPP_HIDE_FROM_ABI bool operator!=(const unique_ptr<_T1, _D1>& __x, const unique_ptr<_T2, _D2>& __y) {
+ return !(__x == __y);
+}
#endif
template <class _T1, class _D1, class _T2, class _D2>
-inline _LIBCPP_HIDE_FROM_ABI
-bool
-operator< (const unique_ptr<_T1, _D1>& __x, const unique_ptr<_T2, _D2>& __y)
-{
- typedef typename unique_ptr<_T1, _D1>::pointer _P1;
- typedef typename unique_ptr<_T2, _D2>::pointer _P2;
- typedef typename common_type<_P1, _P2>::type _Vp;
- return less<_Vp>()(__x.get(), __y.get());
+inline _LIBCPP_HIDE_FROM_ABI bool operator<(const unique_ptr<_T1, _D1>& __x, const unique_ptr<_T2, _D2>& __y) {
+ typedef typename unique_ptr<_T1, _D1>::pointer _P1;
+ typedef typename unique_ptr<_T2, _D2>::pointer _P2;
+ typedef typename common_type<_P1, _P2>::type _Vp;
+ return less<_Vp>()(__x.get(), __y.get());
}
template <class _T1, class _D1, class _T2, class _D2>
-inline _LIBCPP_HIDE_FROM_ABI
-bool
-operator> (const unique_ptr<_T1, _D1>& __x, const unique_ptr<_T2, _D2>& __y) {return __y < __x;}
+inline _LIBCPP_HIDE_FROM_ABI bool operator>(const unique_ptr<_T1, _D1>& __x, const unique_ptr<_T2, _D2>& __y) {
+ return __y < __x;
+}
template <class _T1, class _D1, class _T2, class _D2>
-inline _LIBCPP_HIDE_FROM_ABI
-bool
-operator<=(const unique_ptr<_T1, _D1>& __x, const unique_ptr<_T2, _D2>& __y) {return !(__y < __x);}
+inline _LIBCPP_HIDE_FROM_ABI bool operator<=(const unique_ptr<_T1, _D1>& __x, const unique_ptr<_T2, _D2>& __y) {
+ return !(__y < __x);
+}
template <class _T1, class _D1, class _T2, class _D2>
-inline _LIBCPP_HIDE_FROM_ABI
-bool
-operator>=(const unique_ptr<_T1, _D1>& __x, const unique_ptr<_T2, _D2>& __y) {return !(__x < __y);}
-
+inline _LIBCPP_HIDE_FROM_ABI bool operator>=(const unique_ptr<_T1, _D1>& __x, const unique_ptr<_T2, _D2>& __y) {
+ return !(__x < __y);
+}
#if _LIBCPP_STD_VER >= 20
template <class _T1, class _D1, class _T2, class _D2>
-requires three_way_comparable_with<typename unique_ptr<_T1, _D1>::pointer,
- typename unique_ptr<_T2, _D2>::pointer>
+ requires three_way_comparable_with<typename unique_ptr<_T1, _D1>::pointer, typename unique_ptr<_T2, _D2>::pointer>
_LIBCPP_HIDE_FROM_ABI
-compare_three_way_result_t<typename unique_ptr<_T1, _D1>::pointer,
- typename unique_ptr<_T2, _D2>::pointer>
-operator<=>(const unique_ptr<_T1, _D1>& __x, const unique_ptr<_T2, _D2>& __y) {
- return compare_three_way()(__x.get(), __y.get());
+ compare_three_way_result_t<typename unique_ptr<_T1, _D1>::pointer, typename unique_ptr<_T2, _D2>::pointer>
+ operator<=>(const unique_ptr<_T1, _D1>& __x, const unique_ptr<_T2, _D2>& __y) {
+ return compare_three_way()(__x.get(), __y.get());
}
#endif
@@ -575,108 +512,87 @@ operator==(const unique_ptr<_T1, _D1>& __x, nullptr_t) _NOEXCEPT {
#if _LIBCPP_STD_VER <= 17
template <class _T1, class _D1>
-inline _LIBCPP_HIDE_FROM_ABI
-bool
-operator==(nullptr_t, const unique_ptr<_T1, _D1>& __x) _NOEXCEPT
-{
- return !__x;
+inline _LIBCPP_HIDE_FROM_ABI bool operator==(nullptr_t, const unique_ptr<_T1, _D1>& __x) _NOEXCEPT {
+ return !__x;
}
template <class _T1, class _D1>
-inline _LIBCPP_HIDE_FROM_ABI
-bool
-operator!=(const unique_ptr<_T1, _D1>& __x, nullptr_t) _NOEXCEPT
-{
- return static_cast<bool>(__x);
+inline _LIBCPP_HIDE_FROM_ABI bool operator!=(const unique_ptr<_T1, _D1>& __x, nullptr_t) _NOEXCEPT {
+ return static_cast<bool>(__x);
}
template <class _T1, class _D1>
-inline _LIBCPP_HIDE_FROM_ABI
-bool
-operator!=(nullptr_t, const unique_ptr<_T1, _D1>& __x) _NOEXCEPT
-{
- return static_cast<bool>(__x);
+inline _LIBCPP_HIDE_FROM_ABI bool operator!=(nullptr_t, const unique_ptr<_T1, _D1>& __x) _NOEXCEPT {
+ return static_cast<bool>(__x);
}
#endif // _LIBCPP_STD_VER <= 17
template <class _T1, class _D1>
-inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bool
-operator<(const unique_ptr<_T1, _D1>& __x, nullptr_t) {
+inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bool operator<(const unique_ptr<_T1, _D1>& __x, nullptr_t) {
typedef typename unique_ptr<_T1, _D1>::pointer _P1;
return less<_P1>()(__x.get(), nullptr);
}
template <class _T1, class _D1>
-inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bool
-operator<(nullptr_t, const unique_ptr<_T1, _D1>& __x) {
+inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bool operator<(nullptr_t, const unique_ptr<_T1, _D1>& __x) {
typedef typename unique_ptr<_T1, _D1>::pointer _P1;
return less<_P1>()(nullptr, __x.get());
}
template <class _T1, class _D1>
-inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bool
-operator>(const unique_ptr<_T1, _D1>& __x, nullptr_t) {
+inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bool operator>(const unique_ptr<_T1, _D1>& __x, nullptr_t) {
return nullptr < __x;
}
template <class _T1, class _D1>
-inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bool
-operator>(nullptr_t, const unique_ptr<_T1, _D1>& __x) {
+inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bool operator>(nullptr_t, const unique_ptr<_T1, _D1>& __x) {
return __x < nullptr;
}
template <class _T1, class _D1>
-inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bool
-operator<=(const unique_ptr<_T1, _D1>& __x, nullptr_t) {
+inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bool operator<=(const unique_ptr<_T1, _D1>& __x, nullptr_t) {
return !(nullptr < __x);
}
template <class _T1, class _D1>
-inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bool
-operator<=(nullptr_t, const unique_ptr<_T1, _D1>& __x) {
+inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bool operator<=(nullptr_t, const unique_ptr<_T1, _D1>& __x) {
return !(__x < nullptr);
}
template <class _T1, class _D1>
-inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bool
-operator>=(const unique_ptr<_T1, _D1>& __x, nullptr_t) {
+inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bool operator>=(const unique_ptr<_T1, _D1>& __x, nullptr_t) {
return !(__x < nullptr);
}
template <class _T1, class _D1>
-inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bool
-operator>=(nullptr_t, const unique_ptr<_T1, _D1>& __x) {
+inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bool operator>=(nullptr_t, const unique_ptr<_T1, _D1>& __x) {
return !(nullptr < __x);
}
#if _LIBCPP_STD_VER >= 20
template <class _T1, class _D1>
- requires three_way_comparable<
- typename unique_ptr<_T1, _D1>::pointer> _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23
- compare_three_way_result_t<typename unique_ptr<_T1, _D1>::pointer>
+ requires three_way_comparable< typename unique_ptr<_T1, _D1>::pointer>
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 compare_three_way_result_t<typename unique_ptr<_T1, _D1>::pointer>
operator<=>(const unique_ptr<_T1, _D1>& __x, nullptr_t) {
- return compare_three_way()(__x.get(), static_cast<typename unique_ptr<_T1, _D1>::pointer>(nullptr));
+ return compare_three_way()(__x.get(), static_cast<typename unique_ptr<_T1, _D1>::pointer>(nullptr));
}
#endif
#if _LIBCPP_STD_VER >= 14
-template<class _Tp>
-struct __unique_if
-{
- typedef unique_ptr<_Tp> __unique_single;
+template <class _Tp>
+struct __unique_if {
+ typedef unique_ptr<_Tp> __unique_single;
};
-template<class _Tp>
-struct __unique_if<_Tp[]>
-{
- typedef unique_ptr<_Tp[]> __unique_array_unknown_bound;
+template <class _Tp>
+struct __unique_if<_Tp[]> {
+ typedef unique_ptr<_Tp[]> __unique_array_unknown_bound;
};
-template<class _Tp, size_t _Np>
-struct __unique_if<_Tp[_Np]>
-{
- typedef void __unique_array_known_bound;
+template <class _Tp, size_t _Np>
+struct __unique_if<_Tp[_Np]> {
+ typedef void __unique_array_known_bound;
};
template <class _Tp, class... _Args>
@@ -692,9 +608,8 @@ make_unique(size_t __n) {
return unique_ptr<_Tp>(new _Up[__n]());
}
-template<class _Tp, class... _Args>
- typename __unique_if<_Tp>::__unique_array_known_bound
- make_unique(_Args&&...) = delete;
+template <class _Tp, class... _Args>
+typename __unique_if<_Tp>::__unique_array_known_bound make_unique(_Args&&...) = delete;
#endif // _LIBCPP_STD_VER >= 14
@@ -712,32 +627,30 @@ make_unique_for_overwrite(size_t __n) {
return unique_ptr<_Tp>(new __remove_extent_t<_Tp>[__n]);
}
-template<class _Tp, class... _Args>
+template <class _Tp, class... _Args>
typename __unique_if<_Tp>::__unique_array_known_bound make_unique_for_overwrite(_Args&&...) = delete;
#endif // _LIBCPP_STD_VER >= 20
-template <class _Tp> struct _LIBCPP_TEMPLATE_VIS hash;
+template <class _Tp>
+struct _LIBCPP_TEMPLATE_VIS hash;
template <class _Tp, class _Dp>
#ifdef _LIBCPP_CXX03_LANG
struct _LIBCPP_TEMPLATE_VIS hash<unique_ptr<_Tp, _Dp> >
#else
-struct _LIBCPP_TEMPLATE_VIS hash<__enable_hash_helper<
- unique_ptr<_Tp, _Dp>, typename unique_ptr<_Tp, _Dp>::pointer> >
+struct _LIBCPP_TEMPLATE_VIS hash<__enable_hash_helper< unique_ptr<_Tp, _Dp>, typename unique_ptr<_Tp, _Dp>::pointer> >
#endif
{
#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
- _LIBCPP_DEPRECATED_IN_CXX17 typedef unique_ptr<_Tp, _Dp> argument_type;
- _LIBCPP_DEPRECATED_IN_CXX17 typedef size_t result_type;
+ _LIBCPP_DEPRECATED_IN_CXX17 typedef unique_ptr<_Tp, _Dp> argument_type;
+ _LIBCPP_DEPRECATED_IN_CXX17 typedef size_t result_type;
#endif
- _LIBCPP_HIDE_FROM_ABI
- size_t operator()(const unique_ptr<_Tp, _Dp>& __ptr) const
- {
- typedef typename unique_ptr<_Tp, _Dp>::pointer pointer;
- return hash<pointer>()(__ptr.get());
- }
+ _LIBCPP_HIDE_FROM_ABI size_t operator()(const unique_ptr<_Tp, _Dp>& __ptr) const {
+ typedef typename unique_ptr<_Tp, _Dp>::pointer pointer;
+ return hash<pointer>()(__ptr.get());
+ }
};
_LIBCPP_END_NAMESPACE_STD