Subject: Re: [boost] [interest] rich-typed smart pointers
From: Julian Gonggrijp (j.gonggrijp_at_[hidden])
Date: 2013-10-02 16:41:31
Larry Evans wrote:
> makes it sound useful, especially the section containing:
> Note that rich typed pointers can never be part of multiple
> ownership cycles at the same time. This is a true impossibility
> because at any time exactly one pointer will own a given object.
> However, that statement seems to be contradicted by one just above it:
> Cyclic ownership using data_ptr and move is possible with some
> effort, but cannot happen by accident.
> Could you please clarify?
It is possible to create a ring of owning data_ptrs (with effort, by
design), where each pointer owns the next and the last owns the
first. However, there can be no pointer outside the ring that owns a
pointer inside the ring, because then the pointer inside the ring
would be owned by two other pointers at the same time (i.e. the
previous pointer in the ring as well as the external pointer) and
that's impossible because of the way the rich-typed pointers are
In order for a pointer to be part of two ownership cycles at the
same time it would have to be part of two rings. But then the
previous pointer from ring #1 would own it and be external to ring
#2 (and vice versa). We just saw that this is impossible.
In summary, any data_ptr can be part of at most one ownership cycle
at a time. Other rich-typed pointers cannot be part of any ownership
cycle at all.
Hope this helps!
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk