C++ Logo

std-proposals

Advanced search

Re: [std-proposals] std::shared_ptr resurrect

From: Thiago Macieira <thiago_at_[hidden]>
Date: Mon, 11 Dec 2023 09:26:07 -0800
On Monday, 11 December 2023 08:45:31 PST Valentin Palade wrote:
> Doing a local copy as Jonathan suggests, will make no difference, with
> threads running concurrently, we can still have use_count() return anything
> between 1 and 5.
>
> Or am I missing something?

No. It can be between 1 and 5.

But if it's 1, then you have the only copy and there is no other thread seeing
this object. The number can't change unless the current thread changes it.

-- 
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
   Software Architect - Intel DCAI Cloud Engineering

Received on 2023-12-11 17:26:09