Boost logo

Boost Users :

From: me22 (me22.ca_at_[hidden])
Date: 2007-05-26 12:53:42


On 26/05/07, Constantin Bryzgalin <constb_at_[hidden]> wrote:
> Hello,
>
> > Can anyone tell me why std::vector < boost::ptr_vector < T > > can not be
> > reserved and resized I can not push_back anything inside vector, due to
> > compile errors?
>
> well, creating a copy of ptr_vector raises question of pointer ownership. which one of copies will be responsible for releasing it? if object is to be deleted when it has no referring pointers it looks pretty much like boost::shared_ptr approach. thus if we come to idea of using shared_ptr there seems to be no more reason to use ptr_vector, what you want is std::vector< std::vector< boost::shared_ptr<T> > > instead.
>
My understanding is that copying a ptr_container will (once made
legal) result in the cloning of all of its elements, which means that
there is no ownership problem, but that it's quite expensive (which is
why it's been prohibited).

~ Scott McMurray


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net