From: Andy Glew (glew_at_[hidden])
Date: 2000-01-12 12:30:41
> In implementing a B-tree Container for boost, I have a smart pointer
> need which can't be met by boost::shared_ptr<>; an intrusive
> reference count is required.
Welcome to the club of folks who have been forced to intrusive data
structures, even when we "know" that non-intrusive is "better".
> * The smart pointer needs to support construction from a raw pointer
> when other smart pointers to the same object are known to exist, but
> are not available. This means there needs to be a constructor which
> increments the reference count rather than just setting it to 1.
> (This need derives from a really nice cache design which holds raw
> pointers rather than smart pointers. If smart pointers where held,
> the cached pages would never get released.)
Ahem. Although I have found many uses for intrusive pointers,
it may be that you don't need them here.
If the cache holds a live_ptr<T>, or Greg's weak reference, then
it will not prevent deallocation, and will get zeroed or otherwise
marked. Greg's weak pointer is a non-intrusive version of this.
This being said, in my applications I usually just implement the weak
reference by an intrusive versioned pointer, that checks an object
> 1) General solution: add a boost::shared_in_ptr<> template to
> boost/smart_ptr.hpp which has the same interface as
> boost::shared_ptr<>, except for one additional constructor.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk