On Wed, Oct 8, 2025 at 4:30 PM Marcin Jaczewski <marcinjaczewski86@gmail.com> wrote:
wt., 7 paź 2025 o 23:10 Arthur O'Dwyer via Std-Proposals <std-proposals@lists.isocpp.org> napisał(a):
>
> We obviously can't deprecate `clear()`, nor change its behavior by fiat. That ship sailed very long ago, and `clear()` is a very widely used method.
>
> However, you're right that its semantics are generally underspecified and there is (very slight) vendor divergence:
> https://quuxplusone.github.io/blog/2025/01/02/shrink-to-fit/#how-do-i-clear-and-free-in-one-line
>
> And you're right that in industry code it's usually desirable to (1) have a specific idiom for clearing-and-deallocating, [...]

Question is would be `x = {};` prefered way to clear the container?

https://quuxplusone.github.io/blog/2025/01/02/shrink-to-fit/#how-do-i-clear-and-free-in-one-line
 
It should move the temp object that is empty to the current one.

No, that's not what `x = {};` does at all.

–Arthur