Boost logo

Boost :

From: David B. Held (dheld_at_[hidden])
Date: 2002-04-19 16:42:36


"Darin Adler" <darin_at_[hidden]> wrote in message
news:DD493CCF-53D9-11D6-9E79-0003935B80A2_at_bentspoon.com...
> [...]
> 1) If X is publicly derived from shared_count, it will just work,
> because shared_ptr will find the shared_count part and use it for
> reference counting. There won't be a "detached count".
>
> 2) If X is not publicly derived from shared_count, then the
> shared_ptr constructor for px3 will fail to compile.

I see...that's very clever. Thanks for spelling it out. I didn't notice
the new shared_count.hpp in CVS until Fernando mentioned it. It
all makes sense now. Technically, you need to derive from
counted_base, but I'm sure that's what you meant. ;) So basically,
shared_ptr will act like intrusive_ptr when necessary.

Would it also make sense to add a shared_ptr(counted_base*)
c'tor for geniuses who try to create a shared_ptr from a refcounted
object directly, instead of from intrusive_ptr? Of course, by this
point, one wonders whether a separate intrusive_ptr is really
needed at all (other than that it's a bit more lightweight).

Dave


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