[#BloombergLP-bslma-ManagedPtr-0fa-operator_assign-09]
= xref:BloombergLP.adoc[BloombergLP]::xref:BloombergLP/bslma.adoc[bslma]::xref:BloombergLP/bslma/ManagedPtr-0fa.adoc[ManagedPtr]::operator&equals;
:relfileprefix: ../../../
:mrdocs:

Assignment operators

== Synopses

Declared in `&lt;bslma&lowbar;managedptr&period;h&gt;`

If this object and the specified `rhs` manage the same object, return a reference to this managed pointer&semi; otherwise, destroy the managed object owned by this managed pointer, transfer ownership of the managed object owned by `rhs` to this managed pointer, set this managed pointer to point to the target object referenced by `rhs`, reset `rhs` to empty, and return a reference to this managed pointer&period;


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
xref:BloombergLP/bslma/ManagedPtr-0fa.adoc[ManagedPtr&lt;TARGET&lowbar;TYPE&gt;]&
xref:BloombergLP/bslma/ManagedPtr-0fa/operator_assign-01f.adoc[operator&equals;](xref:BloombergLP/bslma/ManagedPtr-0fa.adoc[ManagedPtr]& rhs) noexcept;
----

[.small]#xref:BloombergLP/bslma/ManagedPtr-0fa/operator_assign-01f.adoc[_» more&period;&period;&period;_]#

If this object and the specified `rhs` manage the same object, return a reference to this managed pointer&semi; otherwise, destroy the managed object owned by this managed pointer, transfer ownership of the managed object owned by `rhs` to this managed pointer, set this managed pointer to point to the target object referenced by `rhs`, reset `rhs` to empty, and return a reference to this managed pointer&period; `TARGET&lowbar;TYPE` must be an accessible and unambiguous base of `BDE&lowbar;OTHER&lowbar;TYPE`&period;


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;class BDE&lowbar;OTHER&lowbar;TYPE&gt;
xref:BloombergLP/bslma/ManagedPtr-0fa.adoc[ManagedPtr&lt;TARGET&lowbar;TYPE&gt;]&
xref:BloombergLP/bslma/ManagedPtr-0fa/operator_assign-013.adoc[operator&equals;](xref:BloombergLP/bslma/ManagedPtr-0fa.adoc[ManagedPtr&lt;BDE&lowbar;OTHER&lowbar;TYPE&gt;]&& rhs) noexcept
requires bsl&colon;&colon;is&lowbar;convertible&lt;BDE&lowbar;OTHER&lowbar;TYPE &ast;, TARGET&lowbar;TYPE &ast;&gt;&colon;&colon;value;
----

[.small]#xref:BloombergLP/bslma/ManagedPtr-0fa/operator_assign-013.adoc[_» more&period;&period;&period;_]#

Destroy the current managed object (if any) and reset this managed pointer to empty&period;


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
xref:BloombergLP/bslma/ManagedPtr-0fa.adoc[ManagedPtr&lt;TARGET&lowbar;TYPE&gt;]&
xref:BloombergLP/bslma/ManagedPtr-0fa/operator_assign-0d.adoc[operator&equals;](xref:bsl/nullptr_t-08.adoc[bsl::nullptr&lowbar;t]);
----

[.small]#xref:BloombergLP/bslma/ManagedPtr-0fa/operator_assign-0d.adoc[_» more&period;&period;&period;_]#

If this object and the managed pointer reference by the specified `ref` manage the same object, return a reference to this managed pointer&semi; otherwise, destroy the managed object owned by this managed pointer, transfer ownership of the managed object owned by the managed pointer referenced by `ref`, and set this managed pointer to point to the target object currently referenced the managed pointer referenced by `ref`&semi; then reset the managed pointer referenced by `ref` to empty, and return a reference to this managed pointer&period; This operator is (implicitly) used to assign from a managed pointer rvalue, or from a managed pointer to a &quot;compatible&quot; type, where &quot;compatible&quot; means a built&hyphen;in conversion from `MANAGED&lowbar;TYPE &ast;` to `TARGET&lowbar;TYPE &ast;` is defined, e&period;g&period;, `derived &ast;` to `base &ast;`, `T &ast;` to `const T &ast;`, or `T &ast;` to `void &ast;`&period;


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
xref:BloombergLP/bslma/ManagedPtr-0fa.adoc[ManagedPtr&lt;TARGET&lowbar;TYPE&gt;]&
xref:BloombergLP/bslma/ManagedPtr-0fa/operator_assign-0b.adoc[operator&equals;](xref:BloombergLP/bslma/ManagedPtr_Ref.adoc[ManagedPtr&lowbar;Ref&lt;TARGET&lowbar;TYPE&gt;] ref) noexcept;
----

[.small]#xref:BloombergLP/bslma/ManagedPtr-0fa/operator_assign-0b.adoc[_» more&period;&period;&period;_]#

If this object and the specified `rhs` manage the same object, return a reference to this managed pointer&semi; otherwise, destroy the managed object owned by this managed pointer, transfer ownership of the managed object owned by `rhs` to this managed pointer, set this managed pointer to point to the target object referenced by `rhs`, reset `rhs` to empty, and return a reference to this managed pointer&period;


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
xref:BloombergLP/bslma/ManagedPtr-0fa.adoc[ManagedPtr&lt;TARGET&lowbar;TYPE&gt;]&
xref:BloombergLP/bslma/ManagedPtr-0fa/operator_assign-0c.adoc[operator&equals;](xref:BloombergLP/bslmf/MovableRef.adoc[bslmf::MovableRef&lt;ManagedPtr&gt;] rhs) noexcept;
----

[.small]#xref:BloombergLP/bslma/ManagedPtr-0fa/operator_assign-0c.adoc[_» more&period;&period;&period;_]#


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