On Tue, 1 Sep 2020 at 20:44, Giuseppe D'Angelo via Development <development@qt-project.org> wrote: > > Il 01/09/20 19:33, Thiago Macieira ha scritto: > > All non-const functions that may detach should be coded so they DO detach. > > That is, after any and all non-const functions, the refcount of the > > container > > should be 1. > > This is the contract, and it's OK. I don't think however that this is > what was intended by OP. Rather, that calling a non-const function may > repack/reallocate a QCC (*), causing invalidation of all references and > iterators, even if the container was NOT shared in the first place. > > Did I misunderstand the problem?
Interesting. I'm curious what sort of repacking happens on erase, and why it wasn't done in such a way that e.g. QVector is 4 pointers instead of 3, so that the element storage wouldn't necessarily be at the beginning of the allocated block; in that approach, a pop_front would merely bump the begin, and erase still wouldn't invalidate anything before the erased position. _______________________________________________ Development mailing list Development@qt-project.org https://lists.qt-project.org/listinfo/development