|
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Member functions | ||||
shared_ptr::operator= | ||||
| Modifiers | ||||
| Observers | ||||
(C++17) | ||||
(until C++20*) | ||||
(C++26) | ||||
(C++26) | ||||
| Non-member functions | ||||
(until C++20)(until C++20)(until C++20)(until C++20)(until C++20)(C++20) | ||||
functions(until C++26*) | ||||
| Helper classes | ||||
(C++20) | ||||
| Deduction guides(C++17) |
shared_ptr& operator=(const shared_ptr& r)noexcept; | (1) | |
template<class Y> shared_ptr& operator=(const shared_ptr<Y>& r)noexcept; | (2) | |
shared_ptr& operator=( shared_ptr&& r)noexcept; | (3) | |
template<class Y> shared_ptr& operator=( shared_ptr<Y>&& r)noexcept; | (4) | |
template<class Y> shared_ptr& operator=(std::auto_ptr<Y>&& r); | (5) | (deprecated in C++11) (removed in C++17) |
template<class Y,class Deleter> shared_ptr& operator=(std::unique_ptr<Y, Deleter>&& r); | (6) | |
Replaces the managed object with the one managed byr.
If*this already owns an object and it is the lastshared_ptr owning it, andr is not the same as*this, the object is destroyed through the owned deleter.
shared_ptr fromr. After the assignment,*this contains a copy of the previous state ofr, andr is empty. Equivalent toshared_ptr<T>(std::move(r)).swap(*this).Contents |
| r | - | another smart pointer to share the ownership to or acquire the ownership from |
*this
The implementation may meet the requirements without creating a temporaryshared_ptr object.
| This section is incomplete Reason: no example |
| replaces the managed object (public member function)[edit] |