From: Frank Mori Hess (fmhess_at_[hidden])
Date: 2008-05-03 14:07:49
On Saturday 03 May 2008 13:52, Peter Dimov wrote:
> Frank Mori Hess:
> > What I'm thinking is more along the lines of how a weak_ptr goes from
> > "expired" to "good". Currently, that can only happen by assignment of
> > a new shared_ptr. And assignment of one expired weak_ptr has no
> > effect on any copies of the weak_ptr, they stay expired.
> This is correct as far as it goes. But in the case I showed, no
> assignment happens to any of the weak_ptr instances. Consider how
> weak_ptrs go from use_count of 1 to use_count of 0 without any
> assignment. This is the same event in reverse. It can't normally occur
> now, of course.
> Remember that use_count() does not report the state of a particular
> instance, it reports program-wide state (the number of shared_ptr
> instances sharing ownership with *this). It can and will go up and down
> without any changes to *this.
Well, okay the changes I described for a "reserved" weak_ptr could be left
as unspecified implementation details, except for the throwing of an
alternate exception for a reserved weak_ptr. Although, it could just
store the "expired or reserved?" information in the bad_weak_ptr object.
As far as I know, there is nothing much specified about what the interface
of the bad_weak_ptr class has to look like.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk