Date: Sat, 15 Feb 2025 11:14:06 -0500
On Sat, Feb 15, 2025 at 5:12 AM Sebastian Wittmeier via Std-Proposals
<std-proposals_at_[hidden]> wrote:
>
> If you use a weak_ptr, it is converted into ashared_ptr for the duration of access.
>
> So it is not enough to disallow copying to make a shared_ptr unique.
True, but without the ability to lock whatever the "weak" reference is
to prevent its deletion while you are using it, you could never use it
in a context where threading is possible. It'd be inherently
dangerous.
I think this idea is just fundamentally flawed. If you want some place
to be able to use it without permanently owning it, then it must be
able to own it *temporarily* (otherwise, it cannot use it safely). And
since it's basically impossible to prevent temporary ownership from
transforming into permanent ownership, it is practically a distinction
without a difference.
<std-proposals_at_[hidden]> wrote:
>
> If you use a weak_ptr, it is converted into ashared_ptr for the duration of access.
>
> So it is not enough to disallow copying to make a shared_ptr unique.
True, but without the ability to lock whatever the "weak" reference is
to prevent its deletion while you are using it, you could never use it
in a context where threading is possible. It'd be inherently
dangerous.
I think this idea is just fundamentally flawed. If you want some place
to be able to use it without permanently owning it, then it must be
able to own it *temporarily* (otherwise, it cannot use it safely). And
since it's basically impossible to prevent temporary ownership from
transforming into permanent ownership, it is practically a distinction
without a difference.
Received on 2025-02-15 16:14:19