In general in c++  mutating a collection invalidates your iterators to it (though vectors and lists have some special rules to make this easier). I'd recommend using `std::move` to copy all the bindings to a temporary map, iterate over that, and put the pointers back in the original map, or delete them (ass appropriate).