How long is a reference to an element returned by an STD collection, such as a map, valid?
For example, in this code:
struct Employee{
int salary;
string name; // the key
};
map<string,Employee> allemployees;
...
Employee & Joe = allemployees["Joe Smith"];
Joe.salary=150; // change "Joe Smith"'s salary
assert(allemployees["Joe Smith"].salary==150); //always true
....
allemployees["Mark Jones"]= Employee();
... // No "Joe Smith" operations in the dots
Joe.salary=200;
assert (allemployees["Joe Smith"].salary==200); //true or not?
}
In other words, I get a value reference back from a map. But then I do various other insertions, deletions and so on the underlying map. Is the original value reference still good? What about for other collections?
And also, how do I know that? I looked in Stroustrup but did not see anything.
Coming from a C background I am confused by references and collections and their interaction. Should I ever consider maps whose values are references themselves? What would that even mean?
So a more general question: where do I find normative answers to this question and similar kinds of questions?
[This is the revised version of a deleted question]