Boost logo

Boost :

From: David Abrahams (dave_at_[hidden])
Date: 2002-09-18 08:54:10


From: "Peter Dimov" <pdimov_at_[hidden]>

<snip>

> Note that the required counted_base derivation (to support
shared_from_this)
> is visible only to the translation unit that contains Impl, a translation
> unit that is typically not visible to the client at all.
>
> Therefore, with this design, shared_from_this is only callable from Impl
> member functions or other implementation details.
>
> Had it been called shared_from_raw, this would imply that a raw to shared
> conversion is of general utility to the client, and because of the
visible
> counted_base requirement, this would steer users towards design #1,
> something that I don't want to do.
>
> This is also one of the reasons that I don't want to attempt any
shared_ptr
> "optimizations" that depend on the template parameter being-a
counted_base.

Very interesting. I learned something. Haven't done any interface-based
design in quite some time; it's nice to see someone thinking about it so
deeply. I hope you'll add this explanation to the rationale or some other
part of the docs.

-----------------------------------------------------------
           David Abrahams * Boost Consulting
dave_at_[hidden] * http://www.boost-consulting.com


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