Skip to main content
added 34 characters in body
Source Link

if you need to erase an element inside of a for-loop, do the following:

for(int i = 0;  while(i < vec.size(); i++){ if(condition) vec.erase(vec.begin() + i); else ++i; } 

if you need to erase an element inside of a for-loop, do the following:

for(int i = 0; i < vec.size(); i++){ if(condition) vec.erase(vec.begin() + i); } 

if you need to erase an element inside of a for-loop, do the following:

int i = 0; while(i < vec.size()){ if(condition) vec.erase(vec.begin() + i); else ++i; } 
Source Link

if you need to erase an element inside of a for-loop, do the following:

for(int i = 0; i < vec.size(); i++){ if(condition) vec.erase(vec.begin() + i); }