Boost logo

Boost :

From: Rainer Deyke (root_at_[hidden])
Date: 2001-07-13 17:36:01


----- Original Message -----
From: "Peter Dimov" <pdimov_at_[hidden]>
To: <boost_at_[hidden]>
Sent: Friday, July 13, 2001 10:01 AM
Subject: Re: 2nd: [boost] shared_ptr proposal

> From: "Christian Thäter" <chth_at_[hidden]>
> > > Excuse me for breaking in where I probably don't belong, but I'm not
> > > sure I'm understanding what you're asking. Do you expect to have the
> > > following semantics?
> > >
> > > shared_ptr<foo> p1(new foo());
> > > shared_ptr<foo> p2(p1);
> > > p1.reset(new foo());
> > > assert(p1.get() == p2.get());
> >
> > Yes
>
> What exactly is wrong with
>
> *p1 = foo();

It doesn't work with derived classes.

class A {};
class B : public A {};
shared_ptr<A> p1(new A);
shared_ptr<A> p2(p1);
*p1 = B(); // Will compile, but semantically incorrect.
p1.reset(new B()); // Not the desired semantics: does not modify 'p2'.

--
Rainer Deyke (root_at_[hidden])
Shareware computer games           -           http://rainerdeyke.com
"In ihren Reihen zu stehen heisst unter Feinden zu kaempfen" - Abigor

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