c++ - Does myVector.erase(myObject) call delete on myObject? -


With Points instead of objects.

If I have the following code

  Foo F; Of vector & lt; Foo & gt; Vect; Vect.push_back (f); Vect.erase (vect.begin ());  

Where does my object go? Is it removed? What if someone else keeps an indicator to do this? Is this a memory leak?

push_back a copy F in the vector, and erase destroys it f itself is not affected by it.

When you erase it is invalid in all the points, references and iterators of an element in a vector erase yields the element after the undefined behavior Use them for


Comments