C++ stl unordered_map implementation, reference validity
问题 For both std::map and std::tr1::unordered_map , I see from the standard that: References to elements in the unordered_map container remain valid in all cases, even after a rehash. How are they doing that ( implementation-wise )? Are they maintaining all the entries as a kind of linked list and then the hash-table just stores pointers to the elements? 回答1: Yes, linked lists are involved, although not quite in the way you suggest. The 2011 standard says (23.2.5 para 8), "The elements of an