boost :: scoped_ptr< T>和std :: unique_ptr< T> [英] Difference between boost::scoped_ptr<T> and std::unique_ptr<T>

查看:184
本文介绍了boost :: scoped_ptr< T>和std :: unique_ptr< T>的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

boost :: scoped_ptr< T> std :: unique_ptr< T> 之间唯一的区别事实上 std :: unique_ptr< T> 有移动语义,而 boost :: scoped_ptr< T> / reset smart pointer?

Is the sole difference between boost::scoped_ptr<T> and std::unique_ptr<T> the fact that std::unique_ptr<T> has move semantics whereas boost::scoped_ptr<T> is just a get/reset smart pointer?

推荐答案

不,但这是最重要的区别。

No, but that is the most important difference.

另一个主要区别是 unique_ptr 可以有一个析构函数对象,类似于 shared_ptr 能够。与 shared_ptr 不同,析构函数类型是 unique_ptr 的一部分(分配器是STL容器类型的一部分)。

The other major difference is that unique_ptr can have a destructor object with it, similarly to how shared_ptr can. Unlike shared_ptr, the destructor type is part of the unique_ptr's type (the way allocators are part of STL container types).

这篇关于boost :: scoped_ptr&lt; T&gt;和std :: unique_ptr&lt; T&gt;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆