Boost logo

Boost :

From: Fernando Cacciola (fcacciola_at_[hidden])
Date: 2002-04-19 16:21:24


"Peter Dimov" <pdimov_at_[hidden]> wrote in message
news:01b101c1e7e2$c057f6e0$1d00a8c0_at_pdimov2...
> From: "Fernando Cacciola" <fcacciola_at_[hidden]>
> > int main()
> > {
> > boost::intrusive_ptr<X> px(new X); // obj's internal count=1
> > boost::intrusive_ptr<X> px2(px); // obj's internal count=2
> > boost::shared_ptr<X> px3(px2); // obj's internal count still =2,
> detached
> > count=1
> >
> > px = 0; // obj's internal count=1
> > px2 = 0; // obj's internal count=0 -----> obj suicides itself....
> >
> > *px3 ; // undefined behavior, pointee no longer alive.
> > }
> >
> > What I am missing?
>
> Try it. :-)
>
OK. I thought that you have *only* added intrusive_ptr<>, but you have
actually changed both shared_ptr<> and shared_count<>.

I'm still not so sure if we really *need* both shared_ptr<> and
intrusive_ptr<>.

Anyway, this appears to work very seamlessly.

--
Fernando Cacciola
Sierra s.r.l.
fcacciola_at_[hidden]
www.gosierra.com

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