Boost logo

Boost :

From: Peter Dimov (pdimov_at_[hidden])
Date: 2004-06-03 06:39:00


Daniel Wallin wrote:
> The weak_ptr docs says this:
>
> weak_ptr();
>
> Effects: Constructs an **empty** weak_ptr.
> Postconditions: use_count() == 0.
>
> long use_count() const;
>
> Returns: if *this is **empty**, an unspecified nonnegative value;
> otherwise, the number of shared_ptr objects that share ownership
> with *this.
>
> use_count() seems underspecified and contradicts weak_ptr(). It should
> return exactly 0 when *this is empty.

Yes, use_count() is underspecified because the Technical Report now requires
use_count() to be zero for all empty pointers. The documentation hasn't been
updated yet to reflect that.

[ That aside, it does not contradict weak_ptr(). The 'unspecified value'
comes from empty weak pointers created from empty shared pointers, not from
the default constructor. :-) ]


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