不是吗
operator=
自己应该打电话
wait
我不知道是不是
想象上的
到,只是粗略地看一下MSVC15.3.4的实现
<future>
似乎强烈建议不要这样做。
//User Code
future f = /*...*/;
f = /*...*/; //(1)
//MSVC Code
future& operator=(future&& _Right) _NOEXCEPT //(1)
{ // assign from rvalue future object
_Mybase::operator=(_STD move(_Right)); //(2)
return (*this);
}
_State_manager& operator=(_State_manager&& _Other) //(2)
{ // assign from rvalue _Other
_Move_from(_Other); //(3)
return (*this);
}
void _Move_from(_State_manager& _Other) //(3)
{ // move stored associated asynchronous state object from _Other
if (this != _STD addressof(_Other))
{ // different, move
if (_Assoc_state)
_Assoc_state->_Release(); //(4)
_Assoc_state = _Other._Assoc_state;
_Other._Assoc_state = 0;
_Get_only_once = _Other._Get_only_once;
}
}
void _Release() //(4)
{ // decrement reference count and destroy when zero
if (_MT_DECR(_Refs) == 0)
_Delete_this(); //(5)
}
void _Delete_this() //(5)
{ // delete this object
if (_Deleter)
_Deleter->_Delete(this); //External Code
else
delete this;
}
视为呼叫
帮助同步事物并确保
future
对象处于要修改的安全状态,最好包括
等待
陈述