std::copyable_function::operator=

From cppreference.com
Utilities library
General utilities
Relational operators (deprecated in C++20)
Integer comparison functions
(C++20)(C++20)(C++20)
(C++20)
Swap and type operations
(C++20)
(C++14)
(C++11)
(C++23)
(C++11)
(C++23)
(C++11)
(C++17)
Common vocabulary types
(C++11)
(C++17)
(C++17)
(C++17)
(C++11)
(C++11)
(C++17)
(C++17)
(C++23)



Function objects
Function invocation
(C++17)(C++23)
Identity function object
(C++20)
Transparent operator wrappers
(C++14)
(C++14)
(C++14)
(C++14)  
(C++14)
(C++14)
(C++14)
(C++14)
(C++14)
(C++14)
(C++14)
(C++14)
(C++14)
(C++14)
(C++14)
(C++14)
(C++14)
(C++14)
(C++14)

Old 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++20*)
(until C++20*)
(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++20*)
(until C++20*)
copyable_function& operator= ( const copyable_function& other ) ;
(1) (since C++26)
copyable_function& operator= ( copyable_function&& other ) ;
(2) (since C++26)
copyable_function& operator= ( std::nullptr_t ) noexcept ;
(3) (since C++26)
template < class F >
copyable_function& operator= ( F&& f ) ;
(4) (since C++26)

Assigns a new target to std::copyable_function or destroys its target.

1) Assigns a copy of the target of other to *this as if by executing auto(other).swap(*this)
2) Moves the target of other to *this or destroys the target of *this (if any) if other is empty, by auto (std:: move (other) ).swap ( *this) . other
3) Destroys the current target if it exists. *this is empty after the call.
4) Sets the target of *this to the callable f, or destroys the current target if f is a null function pointer, a null pointer to member function, or an empty std::copyable_function, as if by executing copyable_function( std::forward <F> (f) ).swap ( *this) ; . This overload participates in overload resolution only if the constructor of copyable_function from F

Parameters

other - another std::copyable_function object to copy or move the target of
f - a callable object to initialize the new target with

Return value

*this

Example

See also

assigns a new target
(public member function of std::function<R(Args...)>)
replaces or destroys the target
(public member function of std::move_only_function)