bsl::shared_ptr::operator=

Assignment operators

Synopses

Declared in <bslstl_sharedptr.h>

Make this shared pointer manage the same modifiable object as the specified rhs shared pointer to the (template parameter) type COMPATIBLE_TYPE, use the same deleter as rhs, and refer to (ELEMENT_TYPE *)rhs.get(); return a reference providing modifiable access to this shared pointer. Note that if rhs is empty, then this shared pointer will also be empty after the assignment. Also note that if *this is the same object as rhs, then this method has no effect.

shared_ptr&
operator=(shared_ptr const& rhs) noexcept;
» more...

Make this shared pointer refer to and manage the same modifiable object as the specified rhs shared pointer to the (template parameter) type COMPATIBLE_TYPE, using the same deleter as rhs and referring to (ELEMENT_TYPE *)rhs.get(), and return a reference to this modifiable shared pointer. If this shared pointer is already managing a (possibly shared) object, then release the shared reference to that object, and destroy it using its associated deleter if this shared pointer held the last shared reference to that object. Note that if rhs is empty, then this shared pointer will also be empty after the assignment. Assign from the specified compatible shared_ptr rhs.

template<class COMPATIBLE_TYPE>
shared_ptr&
operator=(shared_ptr<COMPATIBLE_TYPE> const& rhs) noexcept
requires is_convertible<COMPATIBLE_TYPE *, ELEMENT_TYPE *>::value;
» more...

Make this shared pointer refer to and manage the same modifiable object as the specified rhs shared pointer to the (template parameter) type COMPATIBLE_TYPE, using the same deleter as rhs and referring to (ELEMENT_TYPE *)rhs.get(), and return a reference to this modifiable shared pointer. If this shared pointer is already managing a (possibly shared) object, then release the shared reference to that object, and destroy it using its associated deleter if this shared pointer held the last shared reference to that object. Reset rhs to an empty state, not pointing to any object, unless *this is the same object as rhs. This function does not exist unless a pointer to (template parameter) COMPATIBLE_TYPE is convertible to a pointer to the (template parameter) ELEMENT_TYPE of this shared_ptr. Note that if rhs is empty, then this shared pointer will also be empty after the assignment. Move-assign from the specified compatible shared_ptr rhs.

template<class COMPATIBLE_TYPE>
shared_ptr&
operator=(shared_ptr<COMPATIBLE_TYPE>&& rhs) noexcept
requires is_convertible<COMPATIBLE_TYPE *, ELEMENT_TYPE *>::value;
» more...

Make this shared pointer manage the same modifiable object as the specified rhs shared pointer to the (template parameter) type COMPATIBLE_TYPE, use the same deleter as rhs, and refer to rhs.get(); return a reference providing modifiable access to this shared pointer. Reset rhs to an empty state, not pointing to any object, unless *this is the same object as rhs. Note that if rhs is empty, then this shared pointer will also be empty after the assignment.

shared_ptr&
operator=(BloombergLP::bslmf::MovableRef<shared_ptr> rhs) noexcept;
» more...

Transfer, to this shared pointer, ownership of the modifiable object managed by the specified rhs managed pointer to the (template parameter) type COMPATIBLE_TYPE, and make this shared pointer refer to (ELEMENT_TYPE *)rhs.ptr(). The deleter used in the rhs will be used to destroy the shared object when all references have been released. The default allocator is used to allocate a SharedPtrRep, if needed (users must use the copy-constructor and swap instead of using this operator to supply an alternative allocator). If this shared pointer is already managing a (possibly shared) object, then release the reference to that shared object, and destroy it using its associated deleter if this shared pointer held the last shared reference to that object. Note that if rhs is empty, then this shared pointer will be empty after the assignment. Also note that if rhs owns a reference to another shared object (due to a previous call to shared_ptr<T>::managedPtr) then this shared_ptr will adopt the ManagedPtrs ownership of that shared object.

template<class COMPATIBLE_TYPE>
shared_ptr&
operator=(BloombergLP::bslma::ManagedPtr<COMPATIBLE_TYPE> rhs)
requires is_convertible<COMPATIBLE_TYPE *, ELEMENT_TYPE *>::value;
» more...

Transfer, to this shared pointer, ownership of the modifiable object managed by the specified rhs auto pointer to the (template parameter) type COMPATIBLE_TYPE, and make this shared pointer refer to (ELEMENT_TYPE *)rhs.get(). delete(autoPtr.release()) will be called to destroy the shared object when all references have been released. If this shared pointer is already managing a (possibly shared) object, then release the reference to that shared object, and destroy it using its associated deleter if this shared pointer held the last shared reference to that object. Note that if rhs is empty, then this shared pointer will be empty after the assignment.

template<class COMPATIBLE_TYPE>
shared_ptr&
operator=(std::auto_ptr<COMPATIBLE_TYPE> rhs)
requires is_convertible<COMPATIBLE_TYPE *, ELEMENT_TYPE *>::value;
» more...

Transfer, to this shared pointer, ownership of the object managed by the specified rhs unique pointer to the (template parameter) type COMPATIBLE_TYPE, and make this shared pointer refer to (ELEMENT_TYPE *)rhs.get(). The deleter of rhs will be called to destroy the shared object when all references have been released. If this shared pointer is already managing a (possibly shared) object, then release the reference to that shared object, and destroy it using its associated deleter if this shared pointer held the last shared reference to that object. This function does not exist unless unique_ptr<COMPATIBLE_TYPE, DELETER>::pointer is convertible to ELEMENT_TYPE *. Note that if rhs is empty, then this shared pointer will be empty after the assignment. Also note that this function creates a shared_ptr with an unspecified deleter type that satisfies this contract; the C++11 standard specifies the exact deleter that should be in use after assignment, so this implementation may be non-conforming.

template<
    class COMPATIBLE_TYPE,
    class UNIQUE_DELETER>
shared_ptr&
operator=(std::unique_ptr<COMPATIBLE_TYPE, UNIQUE_DELETER>&& rhs)
requires is_convertible<
            typename std::unique_ptr<COMPATIBLE_TYPE, UNIQUE_DELETER>::pointer,
                                     ELEMENT_TYPE *>::value;
» more...