does std::unique_ptr make boost.pointer container library obsolete in c++11/14?
in c++98/03 there isn't move semantics, , smart pointer shared_ptr has reference-counting related overhead (both ref counting block, , interlocked increment/decrements) if compared raw pointers. std::vector<shared_ptr<t>> has overhead if compared std::vector<t*>.
but std::vector<std::unqiue_ptr<t>> efficient std::vector<t*> (no reference counting overhead), and in addition safe in regard exceptions , automatic destruction (i.e. vector<unique_ptr<t>> destructor automatically call destructors t items pointers stored in vector)?
if so, boost.pointer container still have valid useful place in c++11/14 code, or obsolete?
as james mentions in answer, boost.pointer containers offer more intuitive interface compared sticking unique_ptr standard library container.
aside that, boost::ptr_vector<t> (and friends) store pointed type void * underneath, don't entire class template instantiation every t. not case vector<unique_ptr<t>>.
Comments
Post a Comment