typedef std::map<T> Map;
Map m;

for (Map::iterator it = m.begin(); it != m.end(); ) {
 if (...) {
  m.erase(it++);
 } else {
  ++it;
 }
}