std::map
references are invalidated by the same actions that would invalidate an iterator - that's well documented in the Standard and places like cppreference.com.
Summarily for std::map
, the references are valid as long as you don't clear
the map
, or erase
the specific referenced element; inserting or erasing other elements is fine. For example, cpprefererence map::insert documentation says "No iterators or references are invalidated.".
You'll find there are statements about other containers and their operations....
(jrok pointed out in comments that push to deque
is an example of an operation where references remain valid but iterators are invalidated).