Boost logo

Boost :

From: Braden N. McDaniel (braden_at_[hidden])
Date: 2000-01-15 01:21:00


On Fri, 14 Jan 2000, Kevlin Henney wrote:

> Braden N. McDaniel wrote:
> >> Is there any way to downcast a shared_ptr? That is, the effect of
> >>
> >> shared_ptr<Base> base(new Base);
> >
> >Um. Oops. The above line should of course be
> >
> > shared_ptr<Base> base(new Derived);
> >
> >> shared_ptr<Derived> derived(base);
>
> The short answer is "no, not at the moment".

I'd just about come to that conclusion, but wanted to make sure I hadn't
missed something clever.

> It is unlikely that you would
> want such a narrowing conversion to be implicit: A keyword cast is probably
> the most appropriate solution, eg

Yes, I'm inclined to agree, and this works well. Thanks!

> I recently raised this issue with Greg, who had been aware of it for some
> time.

Seems like a necessary feature to me.

-- 
Braden N. McDaniel
braden_at_[hidden]
<URL:http://www.endoframe.com>

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