Erasing vector::end from vector
The standard doesn’t quite spell it out, but v.erase(q) is defined, “Erases the element pointed to by q” in [sequence.reqmts]. This means that q must actually point to an element, which the end iterator doesn’t. Passing in the end iterator is undefined behavior. Unfortunately, you need to write: auto it = std::find(…); if (it != … Read more