summaryrefslogtreecommitdiff
path: root/include/memory
diff options
context:
space:
mode:
authorEric Fiselier <eric@efcs.ca>2015-08-28 05:07:06 +0000
committerEric Fiselier <eric@efcs.ca>2015-08-28 05:07:06 +0000
commitaff153a8cd0119ef9e60d2c01760796f938f7c9a (patch)
treea99d00f1e6fdc3954bb9491b2c9cd4e53e321dcd /include/memory
parent031a3d203ab2795050492d71da44179939b42bb3 (diff)
[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 git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@246272 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/memory')
-rw-r--r--include/memory11
1 files changed, 9 insertions, 2 deletions
diff --git a/include/memory b/include/memory
index 9d214beb6..4ed33084d 100644
--- a/include/memory
+++ b/include/memory
@@ -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;
}