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?
Sign in to answer questions and track your progress
Sign In