Boost logo

Boost :

From: Larry Evans (jcampbell3_at_[hidden])
Date: 2003-05-28 06:29:09

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
> ( 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.
( )

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.

Boost list run by bdawes at, gregod at, cpdaniel at, john at