[libcxx] Constrain unique_ptr::operator=(unique_ptr<Tp, Dp>) in C++03 mode

Summary:
This patch properly constrains the converting assignment operator in C++03. It also fixes a bug where std::forward was given the wrong type.
The following two tests begin passing in C++03:

* `unique_ptr.single.asgn/move_convert.pass.cpp`
* `unique_ptr.single.asgn/move_convert13.fail.cpp`

Reviewers: mclow.lists

Subscribers: cfe-commits

Differential Revision: http://reviews.llvm.org/D12173

llvm-svn: 246272
This commit is contained in:
Eric Fiselier 2015-08-28 05:07:06 +00:00
parent cb38f75e29
commit d48306e704
1 changed files with 9 additions and 2 deletions

View File

@ -2668,10 +2668,17 @@ public:
: __ptr_(__u->release(), _VSTD::forward<deleter_type>(__u->get_deleter())) {}
template <class _Up, class _Ep>
_LIBCPP_INLINE_VISIBILITY unique_ptr& operator=(unique_ptr<_Up, _Ep> __u)
_LIBCPP_INLINE_VISIBILITY
typename enable_if<
!is_array<_Up>::value &&
is_convertible<typename unique_ptr<_Up, _Ep>::pointer, pointer>::value &&
is_assignable<deleter_type&, _Ep&>::value,
unique_ptr&
>::type
operator=(unique_ptr<_Up, _Ep> __u)
{
reset(__u.release());
__ptr_.second() = _VSTD::forward<deleter_type>(__u.get_deleter());
__ptr_.second() = _VSTD::forward<_Ep>(__u.get_deleter());
return *this;
}