Boost logo

Boost Users :

From: Louis Lavery (Louis_at_[hidden])
Date: 2001-12-14 16:40:34


----- Original Message -----
From: Peter Dimov <pdimov_at_[hidden]>
To: <Boost-Users_at_[hidden]>
Sent: Friday, 14 December, 2001 2:33 PM
Subject: Re: [Boost-Users] Why not "if (px != rpx) " ?

> From: "Louis Lavery" <Louis_at_[hidden]>
> > Hello,
> >
> > The following is use by the boost shared_ptr assignment operators
> > (see boost\smart_ptr.hpp)...
> >
> > void share(T* rpx, long* rpn) {
> > if (pn != rpn) { // Q: why not px != rpx? A: fails when both == 0
> > ++*rpn; // done before dispose() in case rpn transitively
> > // dependent on *this (bug reported by Ken Johnson)
> > dispose();
> > px = rpx;
> > pn = rpn;
> > }
> > } // share
> >
> > ...I curious to know what it means by "fails when both == 0".
>
> It's possible that px == rpx == 0, yet pn != rpn.
>
> --
> Peter Dimov
> Multi Media Ltd.

Hello,

    Yes, I see that, but I can't see what's wrong with using the
test "if ( px != rpx )".

Or, to put it another way, if px == rpx == 0 who cares whether
pn equals rpn or not?

Louis.


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net