function& operator=( const function& other ); | (1) | (since C++11) |
function& operator=( function&& other ); | (2) | (since C++11) |
(3) | ||
function& operator=( std::nullptr_t ); | (since C++11) (until C++17) | |
function& operator=( std::nullptr_t ) noexcept; | (since C++17) | |
template< class F > function& operator=( F&& f ); | (4) | (since C++11) |
template< class F > function& operator=( std::reference_wrapper<F> f ) noexcept; | (5) | (since C++11) |
Assigns a new target to std::function
.
other
, as if by executing function(other).swap(*this);
other
to *this
. other
is in a valid state with an unspecified value.*this
is empty after the call.*this
to the callable f
, as if by executing function(std::forward<F>(f)).swap(*this);
. This operator does not participate in overload resolution unless f
is Callable for argument types Args...
and return type R
. (since C++14)
*this
to a copy of f
, as if by executing function(f).swap(*this);
other | - | another std::function object to copy the target of |
f | - | a callable to initialize the target with |
Type requirements | ||
-F must meet the requirements of Callable. |
*this
.
Even before allocator support was removed from std::function
in C++17, these assignment operators use the default allocator rather than the allocator of *this
or the allocator of other
(see LWG #2386).
(until C++17) | assigns a new target (public member function) |
© cppreference.com
Licensed under the Creative Commons Attribution-ShareAlike Unported License v3.0.
http://en.cppreference.com/w/cpp/utility/functional/function/operator=