me22
On 26/05/07, Constantin Bryzgalin
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.
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).
I would hope that no one who writes useful algorithms tries to prohibit reasonable actions from taking place just because they're expensive. It is not up to library designers to save programmers from themselves; programmers can always write inefficient code if they choose not to think carefully about what they're doing. This is one of the founding principles of the Standard Template Library, and one that should continue to guide Boost. Mark Ruzon