https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86013

--- Comment #6 from Jan Kratochvil <jan.kratochvil at redhat dot com> ---
(In reply to Marc Glisse from comment #5)
> I can't find anywhere a guarantee that realloc doesn't move stuff when the
> new size is smaller than the old.

In practice it does not.


> What would be the point of shrink_to_fit() otherwise? It was created as a
> nicer alternative for people who were copying to a new temporary vector and
> swapping them.

It should be implemented in the most optimal way. ISO C++ standard does not
talk about any copying:
https://stackoverflow.com/questions/2664051/why-is-shrink-to-fit-non-binding/2664094

Reply via email to