Alternatives to std::vector due to reallocation that invalidates pointers to elements
问题 this might be a newb question (i am) but i've searched as much as i could to find a solution to the following problem I have the following scenario (heavily distilled of course): class Container { std::vector<Object> obj; }; class Pointers { std::vector<Object*> obj_ptr; }; I have a routine that pushes back an element of type Object to the vector obj in Container then pushes back the pointer to that same element to obj_ptr . the overall idea is that obj_ptr[i] == &obj[i] throughout the life