std::function::operator=

From cppreference.com
< cpp‎ | utility‎ | functional‎ | function
 
 
 
Function objects
Function wrappers
(C++11)
(C++11)
(C++17)
Bind
(C++11)
(C++11)
(C++11)
Reference wrappers
(C++11)(C++11)
Operator wrappers
Negators
Deprecated binders and adaptors
(until C++17)
(until C++17)
(until C++17)
(until C++17)
(until C++17)(until C++17)(until C++17)(until C++17)
(until C++17)
(until C++17)(until C++17)(until C++17)(until C++17)
(until C++17)(until C++17)
(until C++17)(until C++17)
 
 
function& operator=( const function& other );
(1) (since C++11)
function& operator=( function&& other );
(2) (since C++11)
function& operator=( std::nullptr_t );
(3) (since C++11)
template< class F >
function& operator=( F&& f );
(4) (since C++11)
template< class F >
function& operator=( std::reference_wrapper<F> f );
(5) (since C++11)

Assigns a new target to std::function.

1) Assigns a copy of target of other, as if by executing function(other).swap(*this);
2) Moves the target of other to *this. other is in a valid state with an unspecified value.
3) Drops the current target. *this is empty after the call.
4) Moves the callable f to the target of *this, 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)
5) Assigns a copy of f, as if by executing function(f).swap(*this);

Contents

[edit] Parameters

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.

[edit] Return value

*this

[edit] Exceptions

1-2) (none)
3)

(none)

(until C++17)
noexcept specification:  
noexcept
  
(since C++17)
4) (none)
5)
noexcept specification:  
noexcept
  

[edit] See also

assigns a new target
(public member function)