|
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Member functions | ||||
weak_ptr::operator= | ||||
| Modifiers | ||||
| Observers | ||||
(C++26) | ||||
(C++26) | ||||
| Non-member functions | ||||
| Helper classes | ||||
(C++20) | ||||
| Deduction guides(C++17) |
weak_ptr& operator=(const weak_ptr& r)noexcept; | (1) | (since C++11) |
template<class Y> weak_ptr& operator=(const weak_ptr<Y>& r)noexcept; | (2) | (since C++11) |
template<class Y> weak_ptr& operator=(const shared_ptr<Y>& r)noexcept; | (3) | (since C++11) |
weak_ptr& operator=( weak_ptr&& r)noexcept; | (4) | (since C++11) |
template<class Y> weak_ptr& operator=( weak_ptr<Y>&& r)noexcept; | (5) | (since C++11) |
Replaces the managed object with the one managed byr. The object is shared withr. Ifr manages no object,*this manages no object too.
Contents |
| r | - | smart pointer to share an object with |
*this
The implementation may meet the requirements without creating a temporaryweak_ptr object.
The following behavior-changing defect reports were applied retroactively to previously published C++ standards.
| DR | Applied to | Behavior as published | Correct behavior |
|---|---|---|---|
| LWG 2315 | C++11 | move semantic was not enabled forweak_ptr | enabled |
creates a newweak_ptr(public member function)[edit] | |
| swaps the managed objects (public member function)[edit] |