[#bsl-shared_ptr-0a-operator_assign-090] = xref:bsl.adoc[bsl]::xref:bsl/shared_ptr-0a.adoc[shared_ptr]::operator= :relfileprefix: ../../ :mrdocs: Assign from a unique pointer, taking ownership of `rhs`. == Synopsis Declared in `<bslstl_sharedptr.h>` [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- template< class COMPATIBLE_TYPE, class UNIQUE_DELETER> xref:bsl/shared_ptr-0a.adoc[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; ---- == Description 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. == Return Value reference providing modifiable access to this shared pointer == Parameters [cols="1,4"] |=== | Name| Description | *rhs* | right‐hand side operand |=== [.small]#Created with https://www.mrdocs.com[MrDocs]#