Date: Thu, 24 Jul 2025 10:12:38 +0200
Dropping can be done by relocating out of the variable with no target.
What is the state of standardization for relocation
-----Ursprüngliche Nachricht-----
Von:Simon Schröder via Std-Proposals <std-proposals_at_[hidden]>
Gesendet:Do 24.07.2025 10:00
Betreff:Re: [std-proposals] Similar to [[no_discard]], but store in a variable, maybe call it [[must_store]]
An:std-proposals_at_[hidden];
CC:Simon Schröder <dr.simon.schroeder_at_[hidden]>;
On Tue, Jul 22, 2025 at 3:48 PM Sebastian Wittmeier via Std-Proposals <std-proposals_at_[hidden] <mailto:std-proposals_at_[hidden]> > wrote:
It does, what it should. Is it short? Is it pretty? Not sure.
Scopes work in a lot of cases. However, the ideal solution might be overlapping scopes in some cases.
I want to bring back an idea from Rust: It has a drop() function which will call the destructor of an object immediately (and thus officially ends the lifetime of an object). It better states the goal of ending the lifetime explicitly than nested scopes.
I would say that drop() is longer than scopes (at least number of keystrokes), but it is one less line to read. Maybe it is not short, but it is concise. And I would claim it is much prettier than scopes.
--
Std-Proposals mailing list
Std-Proposals_at_[hidden]
https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals
Received on 2025-07-24 08:22:28