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

Assign from a managed 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&gt;
xref:bsl/shared_ptr-0a.adoc[shared&lowbar;ptr]&
operator&equals;(xref:BloombergLP/bslma/ManagedPtr-0fa.adoc[BloombergLP::bslma::ManagedPtr&lt;COMPATIBLE&lowbar;TYPE&gt;] rhs)
requires is&lowbar;convertible&lt;COMPATIBLE&lowbar;TYPE &ast;, ELEMENT&lowbar;TYPE &ast;&gt;&colon;&colon;value;
----

== Description

Transfer, to this shared pointer, ownership of the modifiable object managed by the specified `rhs` managed pointer to the (template parameter) type `COMPATIBLE&lowbar;TYPE`, and make this shared pointer refer to `(ELEMENT&lowbar;TYPE &ast;)rhs&period;ptr()`&period; The deleter used in the `rhs` will be used to destroy the shared object when all references have been released&period; The _default_ _allocator_ is used to allocate a `SharedPtrRep`, if needed (users must use the copy&hyphen;constructor and swap instead of using this operator to supply an alternative allocator)&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; Note that if `rhs` is empty, then this shared pointer will be empty after the assignment&period; Also note that if `rhs` owns a reference to another shared object (due to a previous call to `shared&lowbar;ptr&lt;T&gt;&colon;&colon;managedPtr`) then this `shared&lowbar;ptr` will adopt the `ManagedPtr`s ownership of that shared object&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]#
