From aff153a8cd0119ef9e60d2c01760796f938f7c9a Mon Sep 17 00:00:00 2001 From: Eric Fiselier Date: Fri, 28 Aug 2015 05:07:06 +0000 Subject: [PATCH] [libcxx] Constrain unique_ptr::operator=(unique_ptr) 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 --- include/memory | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/include/memory b/include/memory index 9d214beb..4ed33084 100644 --- a/include/memory +++ b/include/memory @@ -2668,10 +2668,17 @@ public: : __ptr_(__u->release(), _VSTD::forward(__u->get_deleter())) {} template - _LIBCPP_INLINE_VISIBILITY unique_ptr& operator=(unique_ptr<_Up, _Ep> __u) + _LIBCPP_INLINE_VISIBILITY + typename enable_if< + !is_array<_Up>::value && + is_convertible::pointer, pointer>::value && + is_assignable::value, + unique_ptr& + >::type + operator=(unique_ptr<_Up, _Ep> __u) { reset(__u.release()); - __ptr_.second() = _VSTD::forward(__u.get_deleter()); + __ptr_.second() = _VSTD::forward<_Ep>(__u.get_deleter()); return *this; }