[Development] Important recent changes in QList/QString/QByteArray

Julien Cugnière julien.cugniere at gmail.com
Thu Sep 10 08:21:40 CEST 2020


Le mer. 9 sept. 2020 à 15:38, Andrei Golubev <andrei.golubev at qt.io> a écrit :
>
> I don't understand what this means. Am I supposed to reserve a
> container to its current size before erasing elements
> from it, if I don't want the erase to shrink it?
>
> Yes.

For what it's worth, as a user, I think this would violate the
principle of least surprise. I would expect QCC in Qt6 to behave like
std::vector, and like QCC in Qt5 : an erase never shrinks the
allocated memory. If I want to reclaim memory, I must explicitly use
shrink_to_fit/squeeze.


More information about the Development mailing list