3 ms·
dmpk2k is right: the requirements on iterator validity are the obvious consequences of using a reallocatable array. Replace a std::vector with malloc-ed memory
by maxlybbert 12y ago
dmpk2k is right: the requirements on iterator validity are the obvious consequences of using a reallocatable array. Replace a std::vector with malloc-ed memory and call realloc every so often, and you'll find your pointers to elements in the array don't stay valid. It's not a gratuitous problem; you'd run into it no matter how you implement your grow able array.
Interestingly, keeping track of indexes into the array avoids the issue completely.