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

Иван Комиссаров abbapoh at gmail.com
Tue Sep 1 22:06:39 CEST 2020

Sorry, but you’re wrong here. Cppreference clearly says

Invalidates iterators and references at or after the point of the erase, including the end() <https://en.cppreference.com/w/cpp/container/vector/end> iterator.

https://en.cppreference.com/w/cpp/container/vector/erase <https://en.cppreference.com/w/cpp/container/vector/erase>

It says nothing about invalidating references before the point of insertion

I expect QVector/QList behave exactly like that (if it is not shared like in the example in the first mail).

I’d rather prefer not to read another 10 blog posts «how not to shoot in the leg with Qt6 QList»


> 1 сент. 2020 г., в 19:31, Thiago Macieira <thiago.macieira at intel.com> написал(а):
> On Tuesday, 1 September 2020 09:05:48 PDT NIkolai Marchenko wrote:
>> Wait what? The switch to Qt6 was supposed to become a painless process yet
>> you're introducing important and hard to notice in real code changes that
>> can result in undefined behaviour?
>> What? WHAT?!
> There's no violation. Your code was incorrect in the past, it just happened to 
> work.
> Assume any and all non-const function will invalidate iterators.
> -- 
> Thiago Macieira - thiago.macieira (AT) intel.com
>  Software Architect - Intel DPG Cloud Engineering
> _______________________________________________
> Development mailing list
> Development at qt-project.org
> https://lists.qt-project.org/listinfo/development

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/development/attachments/20200901/3c8af2ee/attachment-0001.html>

More information about the Development mailing list