14 Dec
2001
14 Dec
'01
9:41 p.m.
On 12/14/01 1:40 PM, "Louis Lavery"
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?
If both px and rpx are 0, but pn and rpn are the same, then the dispose() will cause the single object pointed to by pn to be deleted. Then pn will point to freed memory. And dereferencing pn will result in undefined behavior. And destroying the shared_ptr will result in undefined behavior because it will try to delete the same thing again. -- Darin