I have two std::maps:
std::map<int,int> map1;
std::map<int,int> map2;
I need to iterate over one backwards and the other forwards (because that is the pattern of data access). Whilst iterating I would like to be able to erase elements continue iterating.
I would like to use the same method.
I have seen examples using templates showing how to iterate bidirectionally, but doesn't demonstrate erasing elements (and this is important because erase() only works with forward iterators):
Iterating over a container bidirectionally
and I have seen reverse_iterator examples which erase, but they aren't bidirectional:
How to call erase with a reverse iterator using a for loop
but I would like to iterate bidirectionally and erase?