[Solved] Vector iterators incompatible error for a vector holding iterators of another vector


push_back might cause a reallocation of the data contained in the vector. And that reallocation will make all iterators to the vector invalid. Dereferencing invalid iterators leads to undefined behavior.

Indexes into the vector will continue to stay valid, unless you remove elements from the vector.

2

solved Vector iterators incompatible error for a vector holding iterators of another vector