For a unordered_map erase(), I have seen a few threads suggesting different methods for doing it (like getting the next element from the return of erase()). However, I haven't seen anybody suggesting the following. So, I was wondering if there is some issue with this approach:
for (auto it1 = map.begin(); it1 != map.end(); )
{
auto it2 = it1++; //it2 assigned before it1 incremented
map.erase(it2);
}