std::copyable_function::operator=
来自cppreference.com
< cpp | utility | functional | copyable function
copyable_function& operator=( const copyable_function& other ); |
(1) | (C++26 起) |
copyable_function& operator=( copyable_function&& other ); |
(2) | (C++26 起) |
copyable_function& operator=( std::nullptr_t ) noexcept; |
(3) | (C++26 起) |
template< class F > copyable_function& operator=( F&& f ); |
(4) | (C++26 起) |
赋值新目标给 std::copyable_function
或销毁其目标。
1) 赋值
other
的目标的副本给 *this,如同执行 auto(other).swap(*this)。2) 移动
other
的目标给 *this,或者若 other
为空时销毁 *this 的目标(如果有),执行 auto(std::move(other)).swap(*this)。移动复制之后 other
处于有效状态并具有未指明的值。3) 若存在当前目标则销毁之。调用后 *this 为空。
4) 将 *this 的目标设为可调用体
f
,或者若 f
为空指针值、空成员指针值或空 std::copyable_function
时销毁当前目标,如同执行 copyable_function(std::forward<F>(f)).swap(*this);。此重载只有在F
的 copyable_function
参与重载解析时才会参与重载决议。如果所选中的构造函数调用非良构或具有未定义行为,则程序非良构或具有未定义行为。[编辑] 参数
other | - | 要复制或移动目标的另一 std::copyable_function 对象
|
f | - | 用以初始化新目标的可调用对象 |
[编辑] 返回值
*this
[编辑] 参阅
赋值新的目标 ( std::function<R(Args...)> 的公开成员函数)
| |
替换或销毁目标 ( std::move_only_function 的公开成员函数)
|