Boost logo

Boost :

From: Beman Dawes (beman_at_[hidden])
Date: 2000-01-12 10:37:30


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. (Of the three reasons, the last one is
the killer.)

* Since the smart point goes in an iterator, it would be better to
avoid the size and separate allocation penalty of shared_ptr.

* Memory allocation should use the container's Allocator.

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

There are two ways I can see to deal with this:

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.

2) Specific solution: supply a minimal pointer within the B-tree
implementation that solves that specific problem only.

Opinions, anyone?

--Beman


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