Boost logo

Boost :

From: Larry Evans (jcampbell3_at_[hidden])
Date: 2003-06-01 22:00:14


Chuck Messenger wrote:
> Schoenborn, Oliver wrote:
[snip]
>>
>> ... 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,
>
>
> Which is why the strict ownership paradigm doesn't work with cyclic
> structures. Inherently, in the general case, cyclic structures
> *require* garbage collection (or to be more precise, some dynammic
> programming cycle-finding algorithm, whether or not you call it "garbage
> collection") to harvest stranded cycles of objects.
>
> Yes, as Peter Dimov suggested, you can sort of "game" the problem by
> dividing your structures into Vertex and Edge types, allowing for a
> classic strict ownership hierarchy. But that just leaves the garbage
> collection problem to the programmer.
OTOH,

http://groups.google.com/groups?dq=&hl=en&lr=&ie=UTF-8&oe=UTF-8&threadm=dilpugnc13c.fsf%40isolde.research.att.com&rnum=1&prev=/groups%3Fdq%3D%26hl%3Den%26lr%3D%26ie%3DUTF-8%26oe%3DUTF-8%26selm%3Ddilpugnc13c.fsf%2540isolde.research.att.com

seems to support Oliver's viewpoint. I remember reading another post
somewhere where someone required cycles because he was
creating a graph from reading input from a file and couldn't know who
owned who. However, if he's reading from a file, he must
have some map from vertex_name -> vertex_node, and this map
would be the sole owner. All the vertex_nodes would simply be
weak_ptr's to other vertex_nodes.

The above cited post was in a long thread discussing on this topic.
It might be worth reading.


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