Allegedly you cannot just erase/remove an element in a container while iterating as iterator becomes invalid. What are the (safe) ways to remove the elements that meet a cer
You can as long as you don't invalidate your iterator after you've erased it:
MyContainer::iterator it = myContainer.begin(); while(it != myContainer.end()) { if (*it == matchingValue) { myContainer.erase(it++); } else { ++it; } }