Consider the following:
std::unordered_map<int, std::array<float,50>> foo;
...
auto pointerToArray = foo.at(3).data();
I have read this and this. I have the following questions:
- 1) pointerToArrayfalls into which category when referring to the invalidation rules, iterator or reference?
- 2) What are the risks that pointerToArraywill get invalidated (assuming its paired key infoois not erased)?
- 3) What, if any, difference is there in the answers to these
questions between unordered_mapandmap?
Unlike vector, array itself will not re-allocate and thus there is not a risk of it changing memory addresses on its own, but as it is inside a unordered/map, the plot thickens.
Update: Found another question that suggests there is no risk of invalidation in this case.
 
     
    