Which Handles Survive

Four handles are taken, then 98 more elements go into each container:

std::map<int, std::string> m;
std::unordered_map<int, std::string> um;
m[1] = "one";
um[1] = "one";

std::string& mref  = m[1];
auto         mit   = m.find(1);
std::string& umref = um[1];
auto         umit  = um.find(1);

for (int k = 2; k < 100; ++k) { m[k] = "x"; um[k] = "x"; }

Which of the four handles are still safe to dereference?

A

Only mit and umit. Iterators are maintained by the container, whereas raw references are not.

B

All of them except umit.

C

All four.

D

Only mref and mit. Any insertion into an unordered container may relocate elements.