Is it legal to have an unordered_map with the value type being a reference C++11?
For example std::unordered_map<std::string, MyClass&>
I have managed to get this to compile with VS2013 however I'm not sure whether it's supposed to as it is causing some strange runtime errors. For example vector subscript out of range is thrown when trying to erase an element.
Some googling resulted in finding out that you can't have a vector of references but I can't find anything about an unordered_map.
Update
Further experimentation has shown that the vector subscript out of range was not related to the unordered_map of references as it was a bug in my code.
std::reference_wrapper.operator[]as it requires the mapped type to beDefaultConstructible(and references aren't). You can't brace-initialize this map, or assign one map to another, as this requires mapped type to beCopyAssignable.