Boost logo

Boost :

From: Schoenborn, Oliver (Oliver.Schoenborn_at_[hidden])
Date: 2003-05-30 09:39:03


> From: Chuck Messenger [mailto:chuckm_at_[hidden]]
> >>No. A and B are completely symmetrical. They each equally
> >>"own" the other.
> >
> >
> > Not possible. This has nothing to do with NoPtr or
> > boost::shared_ptr, it's even true for raw pointers. E.g.
> > ...
>
> Just look at my Node example -- you'll see that there is
> indeed complete symmetry of ownership. There is a cyclic
> ownership graph -- hence the
> trouble with traditional smart pointers.

No because your node example doesn't work, as you showed yourself, the
reference counts (because you were using only shared_ptr) were wrong. I
don't know what your definition of ownership is, but mine is "the one who
contains the object as data member, or, if it contains a pointer to the
object as data member, the one who is in charge of calling delete on the
object when destructed". Strict ownership means that only one object at any
given time can be the owner. This is pretty straightforward and the raw
pointer example shows that there is no such thing as cyclic strict ownership
that works, at least within the above definition of ownership, and the
common definition of cyclic (i.e. A uses B uses "the A that uses the B",
where "uses" would be "owns" or "refers to", depending on your case). Not
even a garbage collector could do it, because the gc is then an owner and
you end up with shared ownership of A.

Oliver


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