In my code the main data structure is
std::vector<std::vector<T>> Worldlines ;
In one of my subroutines I remove and add elements (potentially causing a reallocation of the container to have more capacity) to one of the components (let's say Worldlines[i]
).
If I had some T
in the vector Worldlines[i]
whose positions I saved as std::vector<T>::iterator
objects, they might in general be invalidated if Worldlines[i]
is reallocated.
What about iterators pointing to the T
that belong to the Worldlines[j]
with j != i
? Are they guaranteed to be still valid, or the reallocation of one of the vectors may cause reallocations in the others, since they are bound in a vector of vectors ?
Thanks everyone.