diff --git a/libcxx/include/memory b/libcxx/include/memory --- a/libcxx/include/memory +++ b/libcxx/include/memory @@ -3868,7 +3868,11 @@ #endif // _LIBCPP_NO_EXCEPTIONS typedef typename __shared_ptr_default_allocator<_Yp>::type _AllocT; typedef __shared_ptr_pointer<_Yp*, _Dp, _AllocT > _CntrlBlk; +#ifndef _LIBCPP_CXX03_LANG + __cntrl_ = new _CntrlBlk(__p, std::move(__d), _AllocT()); +#else __cntrl_ = new _CntrlBlk(__p, __d, _AllocT()); +#endif // not _LIBCPP_CXX03_LANG __enable_weak_this(__p, __p); #ifndef _LIBCPP_NO_EXCEPTIONS } @@ -3891,7 +3895,11 @@ #endif // _LIBCPP_NO_EXCEPTIONS typedef typename __shared_ptr_default_allocator<_Tp>::type _AllocT; typedef __shared_ptr_pointer _CntrlBlk; +#ifndef _LIBCPP_CXX03_LANG + __cntrl_ = new _CntrlBlk(__p, std::move(__d), _AllocT()); +#else __cntrl_ = new _CntrlBlk(__p, __d, _AllocT()); +#endif // not _LIBCPP_CXX03_LANG #ifndef _LIBCPP_NO_EXCEPTIONS } catch (...) @@ -3918,7 +3926,11 @@ _A2 __a2(__a); unique_ptr<_CntrlBlk, _D2> __hold2(__a2.allocate(1), _D2(__a2, 1)); ::new(static_cast(_VSTD::addressof(*__hold2.get()))) +#ifndef _LIBCPP_CXX03_LANG + _CntrlBlk(__p, std::move(__d), __a); +#else _CntrlBlk(__p, __d, __a); +#endif // not _LIBCPP_CXX03_LANG __cntrl_ = _VSTD::addressof(*__hold2.release()); __enable_weak_this(__p, __p); #ifndef _LIBCPP_NO_EXCEPTIONS @@ -3946,7 +3958,11 @@ _A2 __a2(__a); unique_ptr<_CntrlBlk, _D2> __hold2(__a2.allocate(1), _D2(__a2, 1)); ::new(static_cast(_VSTD::addressof(*__hold2.get()))) +#ifndef _LIBCPP_CXX03_LANG + _CntrlBlk(__p, std::move(__d), __a); +#else _CntrlBlk(__p, __d, __a); +#endif // not _LIBCPP_CXX03_LANG __cntrl_ = _VSTD::addressof(*__hold2.release()); #ifndef _LIBCPP_NO_EXCEPTIONS } diff --git a/libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer_deleter.pass.cpp b/libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer_deleter.pass.cpp --- a/libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer_deleter.pass.cpp +++ b/libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer_deleter.pass.cpp @@ -28,6 +28,19 @@ int A::count = 0; +template +class MoveDeleter +{ + MoveDeleter(); + MoveDeleter(MoveDeleter const&); +public: + MoveDeleter(MoveDeleter&&) {}; + + explicit MoveDeleter(int) {} + + void operator()(T *ptr) { delete ptr; } +}; + int main(int, char**) { { @@ -46,5 +59,13 @@ assert(test_deleter::count == 0); assert(test_deleter::dealloc_count == 1); +#if TEST_STD_VER >= 11 + { + MoveDeleter d(0); + std::shared_ptr p0(new int, std::move(d)); + std::shared_ptr p1(nullptr, std::move(d)); + } +#endif // TEST_STD_VER >= 11 + return 0; } diff --git a/libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer_deleter_allocator.pass.cpp b/libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer_deleter_allocator.pass.cpp --- a/libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer_deleter_allocator.pass.cpp +++ b/libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer_deleter_allocator.pass.cpp @@ -28,6 +28,18 @@ int A::count = 0; +template +class MoveDeleter +{ + MoveDeleter(); + MoveDeleter(MoveDeleter const&); +public: + MoveDeleter(MoveDeleter&&) {}; + + explicit MoveDeleter(int) {} + + void operator()(T *ptr) { delete ptr; } +}; int main(int, char**) { @@ -85,7 +97,13 @@ assert(A::count == 0); assert(test_deleter::count == 0); assert(test_deleter::dealloc_count == 1); -#endif + + { + MoveDeleter d(0); + std::shared_ptr p2(new int, std::move(d), std::allocator()); + std::shared_ptr p3(nullptr, std::move(d), std::allocator()); + } +#endif // TEST_STD_VER >= 11 return 0; } diff --git a/libcxx/www/cxx1z_status.html b/libcxx/www/cxx1z_status.html --- a/libcxx/www/cxx1z_status.html +++ b/libcxx/www/cxx1z_status.html @@ -458,7 +458,7 @@ 2795§[global.functions] provides incorrect example of ADL useKonaComplete 2796tuple should be a literal typeKonaComplete 2801Default-constructibility of unique_ptrKonaComplete - 2802shared_ptr constructor requirements for a deleterKona + 2802shared_ptr constructor requirements for a deleterKonaComplete 2804Unconditional constexpr default constructor for istream_iteratorKonaComplete 2806Base class of bad_optional_accessKonaComplete 2807std::invoke should use std::is_nothrow_callableKonaComplete