While you erase a iterator in vector,the iterator become a wild pointer in Visual Studio.If you still use it,the compiler will show the access violation reading error.
For another compiler, after removing the element, the vector erase make the iterator return next element.
if you just want to solve it,you can choose ultifinitus's solution.
I had this issue a few weeks ago, it worked with xcode, but not windows. I solved by using a while loop instead of for loop, and putting a Post-increment operator with the iterator being sent as an argument. ( and of course incrementing it in the if part in case if is true )