[#bsl-shared_ptr-0a-operator_assign-090]
= xref:bsl.adoc[bsl]::xref:bsl/shared_ptr-0a.adoc[shared&lowbar;ptr]::operator&equals;
:relfileprefix: ../../
:mrdocs:

Assign from a unique pointer, taking ownership of `rhs`&period;

== Synopsis

Declared in `&lt;bslstl&lowbar;sharedptr&period;h&gt;`

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;
    class COMPATIBLE&lowbar;TYPE,
    class UNIQUE&lowbar;DELETER&gt;
xref:bsl/shared_ptr-0a.adoc[shared&lowbar;ptr]&
operator&equals;(std::unique&lowbar;ptr&lt;COMPATIBLE&lowbar;TYPE, UNIQUE&lowbar;DELETER&gt;&& rhs)
requires is&lowbar;convertible&lt;
            typename std&colon;&colon;unique&lowbar;ptr&lt;COMPATIBLE&lowbar;TYPE, UNIQUE&lowbar;DELETER&gt;&colon;&colon;pointer,
                                     ELEMENT&lowbar;TYPE &ast;&gt;&colon;&colon;value;
----

== Description

Transfer, to this shared pointer, ownership of the object managed by the specified `rhs` unique pointer to the (template parameter) type `COMPATIBLE&lowbar;TYPE`, and make this shared pointer refer to `(ELEMENT&lowbar;TYPE &ast;)rhs&period;get()`&period; The deleter of `rhs` will be called to destroy the shared object when all references have been released&period; 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&period; This function does not exist unless `unique&lowbar;ptr&lt;COMPATIBLE&lowbar;TYPE, DELETER&gt;&colon;&colon;pointer` is convertible to `ELEMENT&lowbar;TYPE &ast;`&period; Note that if `rhs` is empty, then this shared pointer will be empty after the assignment&period; Also note that this function creates a `shared&lowbar;ptr` with an unspecified deleter type that satisfies this contract&semi; the C&plus;&plus;11 standard specifies the exact deleter that should be in use after assignment, so this implementation may be non&hyphen;conforming&period;

== Return Value

reference providing modifiable access to this shared pointer

== Parameters

[cols="1,4"]
|===
| Name| Description
| *rhs*
| right&hyphen;hand side operand
|===


[.small]#Created with https://www.mrdocs.com[MrDocs]#
