Schoenborn, Oliver wrote:
Circular refs are easy to avoid with smart_ptr lib but idiomatically what
you are really looking for is DynObj (and maybe RRef ) in the NoPtr lib
(http://noptrlib.sourceforge.net). Strict ownership is ideal for pimpl and
in particular your example of circular dependency, as supported by the NoPtr
lib.
This sounds like the polaris' RefWrapper (similar to boost weak_ptr) and
Wrapper (similar to your NoPtr) class.  Wrapper's maintain sole "ownership"
of the pointee; however, the owning Wrapper will not delete the pointee if
there are any RefWrapper's pointing to it.  However, any reference to the
pointee (which now has no owner) is detected and a warning issued and
the program aborted.
( 
http://polaris.cs.uiuc.edu/polaris/polaris_developer/node42.html#SECTION00043000000000000000
 )

However, a cycle can still be formed even with single ownership.  A
pointee can contain a Wrapper which points to itself.  I think polaris
had the problem, but it was very rare.  I mentioned this feature one time on
gclist or maybe c++.moderated and someone said it would take a lot of
time to detect dangling pointer references.  I had to say yes, but maybe
it was worth it.

_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost

Reply via email to