Visual Studio (2015) implementation does not invalidate any iterators (rehash() reorders internal std::list, keeping all iterators valid).
Are there other implementations, which invalidate iterators (and achieve better performance, even with the same complexity)?
Invalidating iterators on std::unordered_map::rehash() sometimes can limit developers (e.g. I'm trying to implement LRU cache with std::unordered_map only: with node's value having iterators to the container). But does the possibility to invalidate iterators allow to implement std::unordered_map::rehash() better?
Thanks to @DanielLangr for the discussion above,
I think, this requirement comes with
std::unordered_map::[const_]iteratordefinition asLegacyForwardIterator(and notLegacyBidirectionalIterator). And an implementation with better memory footprint using internalstd::forward_listor similar (instead of VS'std::list) is impossible without invalidating iterators inrehash()(probably, exceptend()).sizeof(std::unordered_map::[const_]iterator), but it is definitely the right thing to definestd::unordered_maprequirements as they are, and leave all those considerations to implementers.