Boost logo

Boost :

From: Peter Dimov (pdimov_at_[hidden])
Date: 2002-01-14 10:13:50


From: "David Abrahams" <david.abrahams_at_[hidden]>
> struct Base { Base(); ~Base(); };
> struct Derived : Base { Derived(); ~Derived(); };
>
> void unsafe()
> {
> shared_ptr<Derived> d(new Derived);
> shared_ptr<Base> b(d);
> d.reset();
> b.reset(); // equivalent to delete (Base*)(new Derived)!!
> };
>
> Isn't shared_ptr just screaming for the application of John Maddock's new
> is_polymorphic<> trait?

The new shared_ptr works. You can even have shared_ptr<void> as b.

--
Peter Dimov
Multi Media Ltd.

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