Possible Duplicate:
How to filter items from a std::map?
What happens if you call erase() on a map element while iterating from begin to end?
I have map of objects and i want to iterate over it and remove some entries.
typedef std::map<A,B> MapT;
MapT m;
MapT::iterator it;
for(it = m.begin(); it != m.end(); it++ ) {
if( condition ) m.erase(it);
}
Can I do it in this way?