I've been getting familiar with C++11 lately, and the auto
keyword is great! Typing:
for (auto bar : bars) {
is oh-so satisfying. Keeps code readable and pretty. What still feels like it stops all your momentum is the following:
foo.insert(std::pair<std::string, bar>("soVerbose", baz));
// As opposed to simply:
foo.insert("soVerbose", baz);
Is there a good reason it is the way it is? And is there some neat way of making it less verbose? I know the []
operator can be used for inserting elements into maps, but the functionality is slightly different.
Use the emplace function: