有什么方法可以阻止用户显式获取唯一指针的所有权
std::move
?
Make it const
The unique_ptr
移动构造函数需要一个非常量右值引用,因此不能用 a 调用const
object.
const unique_ptr<int> owner(new int);
// ...
unique_ptr<int> thief = std::move(owner); // ERROR
这允许unique_ptr
像使用一样boost::scoped_ptr
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)