std::move_only_function::operator=
From cppreference.com
< cpp | utility | functional | move only function
C++
Feature test macros (C++20)
Concepts library (C++20)
Metaprogramming library (C++11)
Ranges library (C++20)
Filesystem library (C++17)
Concurrency support library (C++11)
Execution control library (C++26)
Utilities library
Type support (basic types, RTTI)
Library feature-test macros (C++20)
(C++11)
(C++20)
(C++26)
(C++20)
Coroutine support (C++20)
Contract support (C++26)
(C++20)(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)(C++20)(C++20)
(C++20)(C++20)(C++20)
General utilities
Relational operators (deprecated in C++20)
(C++20)(C++20)(C++20)
(C++20)(C++20)(C++20)
(C++20)
Swap and type operations
Common vocabulary types
Function objects
(C++11)
(C++23)
(C++26)
(C++26)
(C++11)
(C++11)
(C++20)(C++23)
(C++11)
(C++11)
(C++11)
(C++11)
(C++11)
(C++11)(C++11)
(C++20)(C++20)
(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)
(C++17)
(C++17)
(C++17)
(C++17)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(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++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*)
move_only_function& operator=( move_only_function&& other );
(1)
(since C++23)
move_only_function& operator=( const move_only_function& ) = delete;
(2)
(since C++23)
move_only_function& operator=( std::nullptr_t ) noexcept;
(3)
(since C++23)
template< class F >
move_only_function& operator=( F&& f );
(4)
(since C++23)
move_only_function& operator=( F&& f );
Assigns a new target to std::move_only_function
or destroys its target.
1) 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 is in a valid state with an unspecified value after move assignment.
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::move_only_function
, as if by executing move_only_function(std::forward <F>(f)).swap(*this);. This overload participates in overload resolution only if the constructor of move_only_function
from F
participates in overload resolution. The program is ill-formed or has undefined behavior if the selected constructor call is ill-formed or has undefined behavior.Contents
[edit] Parameters
other
-
another
std::move_only_function
object to move the target of
f
-
a callable object to initialize the new target with
[edit] Return value
*this
[edit] Notes
It is intentional not to require the move assignment operator to be noexcept to leave room for an allocator-aware move_only_function
in future.
move_only_function
can be assigned from std::in_place_type <Fn> given it can be constructed from that argument.
[edit] Example
This section is incomplete
Reason: no example
Reason: no example