diff --git a/include/memory b/include/memory index b9f61c27..da8786a2 100644 --- a/include/memory +++ b/include/memory @@ -479,6 +479,8 @@ public: template weak_ptr(shared_ptr const& r) noexcept; weak_ptr(weak_ptr const& r) noexcept; template weak_ptr(weak_ptr const& r) noexcept; + weak_ptr(weak_ptr&& r) noexcept; // C++14 + template weak_ptr(weak_ptr&& r) noexcept; // C++14 // destructor ~weak_ptr(); @@ -487,6 +489,8 @@ public: weak_ptr& operator=(weak_ptr const& r) noexcept; template weak_ptr& operator=(weak_ptr const& r) noexcept; template weak_ptr& operator=(shared_ptr const& r) noexcept; + weak_ptr& operator=(weak_ptr&& r) noexcept; // C++14 + template weak_ptr& operator=(weak_ptr&& r) noexcept; // C++14 // modifiers void swap(weak_ptr& r) noexcept; diff --git a/test/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.assign/weak_ptr.pass.cpp b/test/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.assign/weak_ptr.pass.cpp index 706d19ce..e5713f37 100644 --- a/test/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.assign/weak_ptr.pass.cpp +++ b/test/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.assign/weak_ptr.pass.cpp @@ -59,4 +59,20 @@ int main() } assert(B::count == 0); assert(A::count == 0); + + { + const std::shared_ptr ps(new A); + std::weak_ptr pA(ps); + { + std::weak_ptr pB; + pB = std::move(pA); + assert(B::count == 1); + assert(A::count == 1); + assert(pB.use_count() == 1); + } + assert(B::count == 1); + assert(A::count == 1); + } + assert(B::count == 0); + assert(A::count == 0); } diff --git a/test/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.assign/weak_ptr_Y.pass.cpp b/test/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.assign/weak_ptr_Y.pass.cpp index 76e701fe..5a03d926 100644 --- a/test/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.assign/weak_ptr_Y.pass.cpp +++ b/test/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.assign/weak_ptr_Y.pass.cpp @@ -59,4 +59,20 @@ int main() } assert(B::count == 0); assert(A::count == 0); + + { + const std::shared_ptr ps(new A); + std::weak_ptr pA(ps); + { + std::weak_ptr pB; + pB = std::move(pA); + assert(B::count == 1); + assert(A::count == 1); + assert(pB.use_count() == 1); + } + assert(B::count == 1); + assert(A::count == 1); + } + assert(B::count == 0); + assert(A::count == 0); } diff --git a/test/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.const/weak_ptr.pass.cpp b/test/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.const/weak_ptr.pass.cpp index f0e6c99d..1fdf883a 100644 --- a/test/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.const/weak_ptr.pass.cpp +++ b/test/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.const/weak_ptr.pass.cpp @@ -12,6 +12,7 @@ // weak_ptr // weak_ptr(const weak_ptr& r); +// weak_ptr(weak_ptr &&r) #include #include @@ -51,6 +52,12 @@ struct C int C::count = 0; +template +std::weak_ptr source (std::shared_ptr p) { return std::weak_ptr(p); } + +template +void sink (std::weak_ptr &&) {} + int main() { { @@ -90,4 +97,14 @@ int main() } assert(B::count == 0); assert(A::count == 0); + + { + std::shared_ptr ps(new A); + std::weak_ptr pA = source(ps); + assert(pA.use_count() == 1); + assert(A::count == 1); + sink(std::move(pA)); // kill off the weak pointer + } + assert(B::count == 0); + assert(A::count == 0); } diff --git a/test/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.const/weak_ptr_Y.pass.cpp b/test/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.const/weak_ptr_Y.pass.cpp index 6af46918..70ad11b6 100644 --- a/test/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.const/weak_ptr_Y.pass.cpp +++ b/test/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.const/weak_ptr_Y.pass.cpp @@ -12,6 +12,7 @@ // weak_ptr // template weak_ptr(const weak_ptr& r); +// template weak_ptr(weak_ptr &&r); #include #include @@ -51,6 +52,12 @@ struct C int C::count = 0; +template +std::weak_ptr source (std::shared_ptr p) { return std::weak_ptr(p); } + +template +void sink (std::weak_ptr &&) {} + int main() { static_assert(( std::is_convertible, std::weak_ptr >::value), ""); @@ -92,4 +99,13 @@ int main() } assert(B::count == 0); assert(A::count == 0); + + { + std::shared_ptr ps(new A); + std::weak_ptr pA = source(ps); + std::weak_ptr pB(std::move(pA)); + assert(pB.use_count() == 1); + } + assert(B::count == 0); + assert(A::count == 0); } diff --git a/www/cxx1y_status.html b/www/cxx1y_status.html index 92bc77be..9bd758ea 100644 --- a/www/cxx1y_status.html +++ b/www/cxx1y_status.html @@ -217,10 +217,10 @@ 2291std::hash is vulnerable to collision DoS attackIssaquahComplete 2142packaged_task::operator() synchronization too broad?Issaquah 2240Probable misuse of term "function scope" in [thread.condition]IssaquahComplete - 2252Strong guarantee on vector::push_back() still broken with C++11?Issaquah + 2252Strong guarantee on vector::push_back() still broken with C++11?IssaquahComplete 2257Simplify container requirements with the new algorithmsIssaquahComplete 2268Setting a default argument in the declaration of a member function assign of std::basic_stringIssaquahComplete - 2271regex_traits::lookup_classname specification unclearIssaquah + 2271regex_traits::lookup_classname specification unclearIssaquahComplete 2272quoted should use char_traits::eq for character comparisonIssaquahComplete 2278User-defined literals for Standard Library typesIssaquahComplete 2280begin / end for arrays should be constexpr and noexceptIssaquahComplete @@ -247,8 +247,8 @@ 2308Clarify container destructor requirements w.r.t. std::arrayIssaquahComplete 2313tuple_size should always derive from integral_constantIssaquahComplete 2314apply() should return decltype(auto) and use decay_t before tuple_sizeIssaquah - 2315weak_ptr should be movableIssaquah - 2316weak_ptr::lock() should be atomicIssaquah + 2315weak_ptr should be movableIssaquahComplete + 2316weak_ptr::lock() should be atomicIssaquahComplete 2317The type property queries should be UnaryTypeTraits returning size_tIssaquahComplete 2320select_on_container_copy_construction() takes allocators, not containersIssaquahComplete 2322Associative(initializer_list, stuff) constructors are underspecifiedIssaquahComplete