Why use boost::ptr_vector & Co.

boost::ptr_vector ptr_list ptr_deque ptr_list ptr_set ptr_multiset ptr_map ptr_multimap internally use the stl counterpart on void * pointer, reducing the file object size.

For example using stl::vector any different kind of object pointer require new function, instead of using always the same based on void *.

In the same time ptr_vector have a real descructor, simplify the deleting of object.

  stl::vector<*> boost::ptr_vector
1 8400 10303
2 9046 10535
3 9676 11007
4 10394 11007
5 10936 11299
6 11566 (527 * n) 11531 (204 * n)

file size using from 1 to 6 different object (called class A, class B, class C, ... class F). compiled using g++ -O3 -fno-rtti

Any stl::vector<*> required about 527 new bytes for any different object, instead of 204 only bytes of boost::ptr_vector.

In fact nm -C give the following result:

stl::vector<*>

08048ef0 W std::vector<A*, std::allocator<A*> >::_M_insert_aux(__gnu_cxx::__normal_iterator<A**, std::vector<A*, std::allocator<A*> > >, A* const&)
08049020 W std::vector<B*, std::allocator<B*> >::_M_insert_aux(__gnu_cxx::__normal_iterator<B**, std::vector<B*, std::allocator<B*> > >, B* const&)
08048c90 W std::vector<C*, std::allocator<C*> >::_M_insert_aux(__gnu_cxx::__normal_iterator<C**, std::vector<C*, std::allocator<C*> > >, C* const&)
08048dc0 W std::vector<D*, std::allocator<D*> >::_M_insert_aux(__gnu_cxx::__normal_iterator<D**, std::vector<D*, std::allocator<D*> > >, D* const&)
08048a30 W std::vector<E*, std::allocator<E*> >::_M_insert_aux(__gnu_cxx::__normal_iterator<E**, std::vector<E*, std::allocator<E*> > >, E* const&)
08048b60 W std::vector<F*, std::allocator<F*> >::_M_insert_aux(__gnu_cxx::__normal_iterator<F**, std::vector<F*, std::allocator<F*> > >, F* const&)

boost::ptr_vector<*>

08048df0 W std::vector<void*, std::allocator<void*> >::_M_insert_aux(__gnu_cxx::__normal_iterator<void**, std::vector<void*, std::allocator<void*> > >, void* const&)
08048d50 W std::vector<void*, std::allocator<void*> >::~vector()

and additional symbol inlined are not shown (costructor, push_back and hand made destructor for stl::vector).

On the other hand std::vector<void *> required by boost::ptr_vector could be put in an external library to reduce file size!