Boost logo

Boost :

From: troy d.straszheim (troy_at_[hidden])
Date: 2004-08-07 04:08:19


On Aug 7, 2004, at 3:14 AM, David B. Held wrote:
> troy d.straszheim wrote:
>> shared_ptr<Widget> p = shared_ptr_cast<Widget>(new Widget);
>> [...]
>
> I kinda like the idea as well. In a sense, you *are* converting the
> type of the pointer returned by new from a raw pointer to a
> shared_ptr<>. However, I wonder how much benefit would be derived
> from this change in practice. This would break all existing
> shared_ptr<> code, wouldn't it?

As Rob notes, there's no reason the current practice couldn't remain
legal:

shared_ptr<Widget> p(new Widget); // still OK but not "best practice"

but of course that falls short of the mark w.r.t. *forcing* the
"announcement" of the conversion from raw to shared_ptr via the
shared_ptr_cast<>. I find Rob's observation that the shared_ptr_cast<>
supports specialization for other source types (I knew something good
and obvious was there, duh) compelling.

Would seem reasonable to me to allow both and have the docs reflect
that a cast is preferred, but if the consensus is to turn off the
constructor-from-raw-pointer, if not now, when? As I'm new to the
list, I don't have a good feel for the cost of this in terms of
client-code-breakage, nor for how much emphasis is placed on
backwards-compatibility in boost releases... (relatively little, since
the idea is to hammer out standards-ready designs?)

-t


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