[#bsl-function-0a-operator_assign-01]
= xref:bsl.adoc[bsl]::xref:bsl/function-0a.adoc[function]::operator&equals;
:relfileprefix: ../../
:mrdocs:

Assignment operators

== Synopses

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

Set the target of this object to a copy of the target (if any) held by the specified `rhs` object, destroy the target (if any) previously held by `&ast;this`, and return `&ast;this`&period; The result is equivalent to having constructed `&ast;this` from `rhs` using the extended copy constructor with allocator `this&hyphen;&gt;get&lowbar;allocator()`&period; If an exception is thrown, `&ast;this` is not modified (i&period;e&period;, copy assignment provides the strong exception guarantee)&period;


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
xref:bsl/function-0a.adoc[bsl::function&lt;PROTOTYPE&gt;]&
xref:bsl/function-0a/operator_assign-0f0f.adoc[operator&equals;](xref:bsl/function-0a.adoc[function] const& rhs);
----

[.small]#xref:bsl/function-0a/operator_assign-0f0f.adoc[_» more&period;&period;&period;_]#

Set this object to empty and return `&ast;this`&period;


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
xref:bsl/function-0a.adoc[bsl::function&lt;PROTOTYPE&gt;]&
xref:bsl/function-0a/operator_assign-08.adoc[operator&equals;](xref:bsl/nullptr_t-08.adoc[nullptr&lowbar;t]) noexcept;
----

[.small]#xref:bsl/function-0a/operator_assign-08.adoc[_» more&period;&period;&period;_]#

Set the target of this object to the target (if any) held by the specified `rhs` object, destroy the target (if any) previously held by `&ast;this`, and return `&ast;this`&period; The result is equivalent to having constructed `&ast;this` from `rhs` using the extended move constructor with allocator `this&hyphen;&gt;get&lowbar;allocator()`&period; If an exception is thrown, `rhs` will have a valid but unspecified value and `&ast;this` will not be modified&period; Note that an exception will never be thrown if `get&lowbar;allocator() &equals;&equals; rhs&period;get&lowbar;allocator()`&period;


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
xref:bsl/function-0a.adoc[bsl::function&lt;PROTOTYPE&gt;]&
xref:bsl/function-0a/operator_assign-0f04.adoc[operator&equals;](xref:BloombergLP/bslmf/MovableRef.adoc[BloombergLP::bslmf::MovableRef&lt;function&gt;] rhs);
----

[.small]#xref:bsl/function-0a/operator_assign-0f04.adoc[_» more&period;&period;&period;_]#

Destroy the current target (if any) of this object, then set the target to the specified `rhs` wrapper containing a reference to a callable object and return `&ast;this`&period; The result is equivalent to having constructed `&ast;this` from `rhs` and `this&hyphen;&gt;get&lowbar;allocator()`&period; Note that this assignment is a separate overload only because it is unconditionally `noexcept`&period;


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;class FUNC&gt;
xref:bsl/function-0a.adoc[function]&
xref:bsl/function-0a/operator_assign-05.adoc[operator&equals;](bsl::reference&lowbar;wrapper&lt;FUNC&gt; rhs) noexcept
requires IsInvocableWithPrototype&lt;typename Decay&lt;FUNC&gt;&colon;&colon;type&gt;&colon;&colon;value;
----

[.small]#xref:bsl/function-0a/operator_assign-05.adoc[_» more&period;&period;&period;_]#

Set the target of this object to the specified `rhs` callable object, destroy the previous target (if any), and return `&ast;this`&period; The result is equivalent to having constructed `&ast;this` from `std&colon;&colon;forward&lt;FUNC&gt;(rhs)` and `this&hyphen;&gt;get&lowbar;allocator()`&period; Note that this assignment operator will not participate in overload resolution if `func` is of the same type as this object (to avoid ambiguity with the copy and move assignment operators&period;) In C&plus;&plus;03, instantiation will fail unless `FUNC` is invocable with the arguments and return type specified in `PROTOTYPE`&period; In C&plus;&plus;11 and later, this assignment operator will not participate in overload resolution unless `FUNC` is invocable with the arguments and return type specified in `PROTOTYPE`&period;


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;class FUNC&gt;
xref:bsl/function-0a.adoc[function]&
xref:bsl/function-0a/operator_assign-03.adoc[operator&equals;](FUNC&& rhs)
requires ! IsReferenceCompatible&lt;typename Decay&lt;FUNC&gt;&colon;&colon;type, function&gt;&colon;&colon;value
        &amp;&amp;   IsInvocableWithPrototype&lt;typename Decay&lt;FUNC&gt;&colon;&colon;type&gt;&colon;&colon;value;
----

[.small]#xref:bsl/function-0a/operator_assign-03.adoc[_» more&period;&period;&period;_]#


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