【发布时间】:2020-08-25 16:13:10
【问题描述】:
unique_ptr& operator=(unique_ptr&& _Right) noexcept {
if (this != _STD addressof(_Right)) {
reset(_Right.release());
_Mypair._Get_first() = _STD forward<_Dx>(_Right._Mypair._Get_first());
}
return *this;
}
为什么唯一指针移动赋值运算符用reset()重新分配?
有什么理由不做浅拷贝吗?
【问题讨论】:
标签: c++ c++11 memory smart-pointers unique-ptr