Increment the iterator before it's being erased because erase an element from std map will invalidate the iterator to make it not incrementable.