I’m creating a List like this:
QList<Type> types[LastType];
Then I resize my list:
types[SomeType].reserve(count);
Then later on, when I try to add a type, I do this:
types[SomeType].append(newType);
And it’s giving me an asseration failure on operator[]. So, is it just me or i’m not supposed to be doing it like this? Is there something i’m missing? this is what the error message say: https://i.stack.imgur.com/Cy4uA.png . Removing .reserve does not fix the problem.
So, assuming a
QListis really avectorunder the hood,reserveis the wrong call. You’re not resizing your list as you say, you are asking it to allocate space for at leastsizemore elements. Yes, it allocates more space, but it does not change the size of the list.Sounds like you want
resizehere.