bsl::function::operator=

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).

bsl::function<PROTOTYPE>&
operator=(function const& rhs);
» more...

Set this object to empty and return *this.

bsl::function<PROTOTYPE>&
operator=(nullptr_t) noexcept;
» 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().

bsl::function<PROTOTYPE>&
operator=(BloombergLP::bslmf::MovableRef<function> rhs);
» 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.

template<class FUNC>
function&
operator=(bsl::reference_wrapper<FUNC> rhs) noexcept
requires IsInvocableWithPrototype<typename Decay<FUNC>::type>::value;
» 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.

template<class FUNC>
function&
operator=(FUNC&& rhs)
requires ! IsReferenceCompatible<typename Decay<FUNC>::type, function>::value
        &&   IsInvocableWithPrototype<typename Decay<FUNC>::type>::value;
» more...