Even for a single-threaded execution model, one could have callbacks or cooperarive multi-tasking.
I agree, at least in its simple form the idea is flawed.
-----Ursprüngliche Nachricht-----
Von: Jason McKesson via Std-Proposals <std-proposals@lists.isocpp.org>
Gesendet: Sa 15.02.2025 17:14
Betreff: Re: [std-proposals] A non-owning but self zeroing smart pointer for single ownership
An: std-proposals@lists.isocpp.org;
CC: Jason McKesson <jmckesson@gmail.com>;
On Sat, Feb 15, 2025 at 5:12 AM Sebastian Wittmeier via Std-Proposals
<std-proposals@lists.isocpp.org> 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 mailing list
Std-Proposals@lists.isocpp.org
https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals