[#bsl-function-0a-operator_assign-01] = xref:bsl.adoc[bsl]::xref:bsl/function-0a.adoc[function]::operator= :relfileprefix: ../../ :mrdocs: Assignment operators == Synopses Declared in `<bslstl_function.h>` 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 `*this`, and return `*this`. The result is equivalent to having constructed `*this` from `rhs` using the extended copy constructor with allocator `this‐>get_allocator()`. If an exception is thrown, `*this` is not modified (i.e., copy assignment provides the strong exception guarantee). [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- xref:bsl/function-0a.adoc[bsl::function<PROTOTYPE>]& xref:bsl/function-0a/operator_assign-0f0f.adoc[operator=](xref:bsl/function-0a.adoc[function] const& rhs); ---- [.small]#xref:bsl/function-0a/operator_assign-0f0f.adoc[_» more..._]# Set this object to empty and return `*this`. [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- xref:bsl/function-0a.adoc[bsl::function<PROTOTYPE>]& xref:bsl/function-0a/operator_assign-08.adoc[operator=](xref:bsl/nullptr_t-08.adoc[nullptr_t]) noexcept; ---- [.small]#xref:bsl/function-0a/operator_assign-08.adoc[_» more..._]# 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 `*this`, and return `*this`. The result is equivalent to having constructed `*this` from `rhs` using the extended move constructor with allocator `this‐>get_allocator()`. If an exception is thrown, `rhs` will have a valid but unspecified value and `*this` will not be modified. Note that an exception will never be thrown if `get_allocator() == rhs.get_allocator()`. [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- xref:bsl/function-0a.adoc[bsl::function<PROTOTYPE>]& xref:bsl/function-0a/operator_assign-0f04.adoc[operator=](xref:BloombergLP/bslmf/MovableRef.adoc[BloombergLP::bslmf::MovableRef<function>] rhs); ---- [.small]#xref:bsl/function-0a/operator_assign-0f04.adoc[_» more..._]# 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 `*this`. The result is equivalent to having constructed `*this` from `rhs` and `this‐>get_allocator()`. Note that this assignment is a separate overload only because it is unconditionally `noexcept`. [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- template<class FUNC> xref:bsl/function-0a.adoc[function]& xref:bsl/function-0a/operator_assign-05.adoc[operator=](bsl::reference_wrapper<FUNC> rhs) noexcept requires IsInvocableWithPrototype<typename Decay<FUNC>::type>::value; ---- [.small]#xref:bsl/function-0a/operator_assign-05.adoc[_» more..._]# Set the target of this object to the specified `rhs` callable object, destroy the previous target (if any), and return `*this`. The result is equivalent to having constructed `*this` from `std::forward<FUNC>(rhs)` and `this‐>get_allocator()`. 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.) In C++03, instantiation will fail unless `FUNC` is invocable with the arguments and return type specified in `PROTOTYPE`. In C++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`. [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- template<class FUNC> xref:bsl/function-0a.adoc[function]& xref:bsl/function-0a/operator_assign-03.adoc[operator=](FUNC&& rhs) requires ! IsReferenceCompatible<typename Decay<FUNC>::type, function>::value && IsInvocableWithPrototype<typename Decay<FUNC>::type>::value; ---- [.small]#xref:bsl/function-0a/operator_assign-03.adoc[_» more..._]# [.small]#Created with https://www.mrdocs.com[MrDocs]#