Boost logo

Boost :

From: Schoenborn, Oliver (Oliver.Schoenborn_at_[hidden])
Date: 2003-07-03 10:05:42


> Are you transferring ownership (moving) with copy syntax
> within the containers in order to satisfy the container's copyable
> requirement?

No, transient shared ownership.

> If so, is there not a danger that ownership will get
> accidently transferred out of the container, especially if that
> container is used with some generic algorithm?

>From a syntactic POV, no:
DynObj<T> obj(new T);
std::list< DynObj<T>::InValueContainer > list;
list.push_back(obj.giveAway());
DynObj<T> dynobj = list.front(); //compile error

> And if the container
> itself is copied, which copy owns the pointers?

No way to currently guard against this, except that an assertion will fail
at first attempt to use anything in either of the two containers.

I could sure use some feedback about how the technique stands to generic
algorithms.

Oliver


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk