Boost logo

Boost :

From: Darin Adler (darin_at_[hidden])
Date: 2002-04-24 09:51:43


On Wednesday, April 24, 2002, at 03:23 AM, Peter Dimov wrote:

> I'm still undecided about the case where Y is derived from
> counted_base. The
> current behavior doesn't detect this and allocates an external reference
> count; having two separate reference counts for the same object is
> almost
> always a mistake.
>
> On the other hand, making the constructor autodetect is a semantic
> overload
> (a single function with multiple behaviors) which is typically to be
> avoided
> (it breaks the use_count() == 1 postcondition in some cases.)

One possibility is to overload for the counted_base case and make it an
error to construct a shared_ptr from one of these objects. You could
explicitly construct an intrusive_ptr if you were doing it intentionally.

     -- Darin


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