Skip to content

Commit 64ab1c5

Browse files
Use __nat trick in all modes
1 parent 5102d5d commit 64ab1c5

File tree

1 file changed

+11
-30
lines changed

1 file changed

+11
-30
lines changed

libcxx/include/__memory/unique_ptr.h

Lines changed: 11 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -209,14 +209,10 @@ class _LIBCPP_UNIQUE_PTR_TRIVIAL_ABI unique_ptr {
209209
template <bool _Dummy = true, class = _EnableIfDeleterConstructible<_BadRValRefType<_Dummy> > >
210210
_LIBCPP_HIDE_FROM_ABI unique_ptr(pointer __p, _BadRValRefType<_Dummy> __d) = delete;
211211

212-
#if _LIBCPP_STD_VER >= 20
213-
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unique_ptr(unique_ptr&& __u) noexcept
214-
requires is_move_constructible_v<_Dp>
215-
#else
216-
_LIBCPP_HIDE_FROM_ABI unique_ptr(_If<is_move_constructible<_Dp>::value, unique_ptr&&, __nat> __u) _NOEXCEPT
217-
#endif
218-
: __ptr_(__u.release()), __deleter_(std::forward<deleter_type>(__u.get_deleter())) {
219-
}
212+
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23
213+
unique_ptr(_If<is_move_constructible<_Dp>::value, unique_ptr&&, __nat> __u) _NOEXCEPT
214+
: __ptr_(__u.release()),
215+
__deleter_(std::forward<deleter_type>(__u.get_deleter())) {}
220216

221217
template <class _Up,
222218
class _Ep,
@@ -232,13 +228,8 @@ class _LIBCPP_UNIQUE_PTR_TRIVIAL_ABI unique_ptr {
232228
_LIBCPP_HIDE_FROM_ABI unique_ptr(auto_ptr<_Up>&& __p) _NOEXCEPT : __ptr_(__p.release()), __deleter_() {}
233229
#endif
234230

235-
#if _LIBCPP_STD_VER >= 20
236-
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unique_ptr& operator=(unique_ptr&& __u) noexcept
237-
requires is_move_assignable_v<_Dp>
238-
#else
239-
_LIBCPP_HIDE_FROM_ABI unique_ptr& operator=(_If<is_move_assignable<_Dp>::value, unique_ptr&&, __nat> __u) _NOEXCEPT
240-
#endif
241-
{
231+
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unique_ptr&
232+
operator=(_If<is_move_assignable<_Dp>::value, unique_ptr&&, __nat> __u) _NOEXCEPT {
242233
reset(__u.release());
243234
__deleter_ = std::forward<deleter_type>(__u.get_deleter());
244235
return *this;
@@ -542,24 +533,14 @@ class _LIBCPP_UNIQUE_PTR_TRIVIAL_ABI unique_ptr<_Tp[], _Dp> {
542533
class = _EnableIfPointerConvertible<_Pp> >
543534
_LIBCPP_HIDE_FROM_ABI unique_ptr(_Pp __ptr, _BadRValRefType<_Dummy> __deleter) = delete;
544535

545-
#if _LIBCPP_STD_VER >= 20
546-
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unique_ptr(unique_ptr&& __u) noexcept
547-
requires is_move_constructible_v<_Dp>
548-
#else
549-
_LIBCPP_HIDE_FROM_ABI unique_ptr(_If<is_move_constructible<_Dp>::value, unique_ptr&&, __nat> __u) _NOEXCEPT
550-
#endif
536+
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23
537+
unique_ptr(_If<is_move_constructible<_Dp>::value, unique_ptr&&, __nat> __u) _NOEXCEPT
551538
: __ptr_(__u.release()),
552539
__deleter_(std::forward<deleter_type>(__u.get_deleter())),
553-
__checker_(std::move(__u.__checker_)) {
554-
}
540+
__checker_(std::move(__u.__checker_)) {}
555541

556-
#if _LIBCPP_STD_VER >= 20
557-
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unique_ptr& operator=(unique_ptr&& __u) noexcept
558-
requires is_move_assignable_v<_Dp>
559-
#else
560-
_LIBCPP_HIDE_FROM_ABI unique_ptr& operator=(_If<is_move_assignable<_Dp>::value, unique_ptr&&, __nat> __u) _NOEXCEPT
561-
#endif
562-
{
542+
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unique_ptr&
543+
operator=(_If<is_move_assignable<_Dp>::value, unique_ptr&&, __nat> __u) _NOEXCEPT {
563544
reset(__u.release());
564545
__deleter_ = std::forward<deleter_type>(__u.get_deleter());
565546
__checker_ = std::move(__u.__checker_);

0 commit comments

Comments
 (0)