Assign from a compatible shared_ptr rhs.

Synopsis

Declared in <bslstl_sharedptr.h>

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

Description

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.

Return Value

reference providing modifiable access to this shared pointer

Parameters

Name

Description

rhs

right‐hand side operand

Created with MrDocs