Boost logo

Boost :

From: Peter Dimov (pdimov_at_[hidden])
Date: 2002-01-18 14:41:56


From: "Thomas Maeder" <maeder_at_[hidden]>
> Am 2002.01.18 14:40 schrieb(en) Peter Dimov:
> > The original example was:
> >
> > shared_ptr<Derived> d(new Derived);
> > shared_ptr<Base> b(d);
> > d.reset();
> > b.reset();
> >
> > Which line invokes the undefined behavior? My answer is "none of them"
> > and therefore I have implemented a version of shared_ptr that handles
> > the
> > example fine.
>
> My answer is: The second one.

Possible, but inconvenient. There is no good reason to introduce undefined
behavior here. Consider:

shared_ptr<Derived> d(new Derived);
shared_ptr<Base> b(d);
b.reset();
d.reset();

The second line is the same but it now works (with the current
implementation.)

--
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