I have a std::unordered_map
std::unordered_map<std::string, std::string> myMap;
I want to get a const iterator using find. In c++03 I would do
std::unordered_map<std::string, std::string>::const_iterator = myMap.find("SomeValue");
In c++11 I would want to use auto instead to cut down on the templates
auto = myMap.find("SomeValue");
Will this be a const_iterator or iterator? How does the compiler decide which to use? Is there a way I can force it to choose const?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…