The cleanest approach is to relocate (trivial relocatability was delayed for after C++26) the object into nothing.
That would probably just destruct it, but the compiler would know, not to destruct it a second time.
Moving has to keep the object in a valid state.
Calling the destructor would probably lead to double-destruction.
-----Ursprüngliche Nachricht-----
Von: SD SH <Z5515zwy@outlook.com>
Gesendet: Sa 13.12.2025 02:20
Betreff: Re: [std-proposals] 回复: 回复: 回复: [PXXXXR0] Add a New Keyword ‘undecl’
An: std-proposals@lists.isocpp.org;
CC: Sebastian Wittmeier <wittmeier@projectalpha.org>;
Thinking of more cases, we can move the object, call the destructor, use std::destroy_at or just do nothing until it end, so changing lifetimes is not necessary and it will introduce trouble in managing a object.