Boost :: ptr_vector vs. std :: vector <std :: unique_ptr <T>>?
1 answer
I would prefer std::vector<std::unique_ptr<T>> for several reasons:
- Security type - while this is pretty well abstracted for you in
boost::ptr_vector,ptr_vectoris still implemented in terms ofstd::vector<void*>. - Clear user deletion support - I think you can get user deferral behavior using
boost::ptr_vector, but when usingstd::unique_ptrsupport becomes more clear (and explicit). - It is standard and well supported by compatible C ++ 11 compilers.
+5