$include_dir="/home/hyper-archives/boost/include"; include("$include_dir/msg-header.inc") ?>
From: David Abrahams (dave_at_[hidden])
Date: 2004-01-08 13:12:59
Angus Leeming <angus.leeming_at_[hidden]> writes:
> David Abrahams wrote:
>>> I have this code that use shared_ptr<>::use_count() to
>>> ascertain whether to remove an item from a cache:
>>>
>>> Is that the sort of thing you are interested in?
>>
>> Yep, but unique is not quite the same as use_count.
>
> I guess that I wrote the code without noticing unique()s existence.
> However, I now know of it (thanks ;-) and have checked the code in
> boost/detail/shared_count.hpp:
>
> bool unique() const // nothrow
> {
> return use_count() == 1;
> }
>
> I find that this is exactly what I use myself, so will modify my code
> to use shared_ptr<>::unique().
Will your code work just as well if unique changed to:
bool unique() const // nothrow
{
return weak_count() == 1;
}
??
-- Dave Abrahams Boost Consulting www.boost-consulting.com