From: Thorsten Ottosen (thorsten.ottosen_at_[hidden])
Date: 2006-11-21 16:47:55
Mathias Gaunard wrote:
> Janek Kozicki wrote:
>>Is it possible to use those two together? I'm considering storing my
>>polymorphic stuff into ptr_container but vector (or other standard
>>containers) are not enough for my needs.
>>Using Boost.MultiIndex with Boost.PtrContainer would be great.
> As far as I understand it, pointer containers are more efficient than
> containers of smart pointers because standard containers rely on copy
> semantics instead of move semantics (currently).
That is to some extend true, though we have seen some cloning
smart-pointers posted here on the list that had pretty good efficiency
(the one I'm thinking of was a copy-on-write pointer).
But the differences are more than that. For example, wirh a move_ptr
it's not possible to have containers (that guarantees to be) without
nulls; the pointer containers can keep that invariant because they move
the object and subsequently remove the pointer from the container.
Moving from a standard like container would leave a null sitting there
in the middle of the container.
> But since we're inside of boost, couldn't multi index be smart enough to
> not do copying with smart pointers?
I guess it could. I use a move_ptr by Jonthan Turkanis internally in
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk