boost :: scoped_ptr< T>和std :: unique_ptr< T> [英] Difference between boost::scoped_ptr<T> and 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< T>和std :: unique_ptr< T>的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!