Sunday, 15 January 2012

c++ - boost::ptr_vector vs. std::vector<std::unique_ptr>? -



c++ - boost::ptr_vector vs. std::vector<std::unique_ptr<T>>? -

they similar things.

what should considered when choosing between two?

under circumstances either 1 preferred?

i prefer std::vector<std::unique_ptr<t>> several reasons:

type safety -- while pretty abstracted in boost::ptr_vector, ptr_vector still implemented in terms of std::vector<void*>. clear back upwards custom deleter -- think can custom deleter behavior boost::ptr_vector, back upwards clearer (and explicit) when using std::unique_ptr. it's standard, , supported compliant c++11 compilers.

c++ pointers boost vector

No comments:

Post a Comment