From: Gennadiy Rozental (rogeeff_at_[hidden])
Date: 2002-04-27 12:56:28


"Peter Dimov" <pdimov_at_[hidden]> wrote in message
news:001101c1edd1$3452bd70$1d00a8c0_at_pdimov2...
> From: "Gennadiy Rozental" <rogeeff_at_[hidden]>
> > 9. I checked current smart_ptr_test.cpp using my generators. With
> exclusion
> > of missing operator[] all test are passing (well, 3 are failing but this
> is
> > because I have for smart_ptr<...> v => v.use_count() = 0, while current
> > implementation gives 1. Is there specific reason why is that? )
>
> use_count() is the number of shared_ptr copies in existence.
>
> shared_ptr<int> v; // v.use_count() == 1
> shared_ptr<int> v2(v); // v.use_count() == 2
>
> use_count() == 0 means no shared_ptr objects; this is only possible when
you
> check the use_count() via a weak_ptr.

I treat use_count as a number of references. And since shared_ptr<int> v;
does not have a reference to any real object use_count is zero (also,
depends on implementation shared_ptr may not have a counter allocated by
this time). In general I am not sure that shared_ptr need this interface at
all. For testing purposes we could use external facility (see my test
program).

Gennadiy.