That syntax of:
std::map<int, int> m; m.insert(std::make_pair(1, 42)); seems a bit crazy.
Why is there no alternative insert(K k, V v) method which would provide a much saner:
std::map<int, int> m; m.insert(1, 42); Yes, I'm aware of m[1] = 42, but it has its own problems (creating an extra copy of the value object).
m.emplace(1, 42)?mapalready worked like this in the original STL before it was incorporated into the standard library, and since the container's value type is a pair, using a pair as the parameter type is simply the most logical way. AFAIK,operator[]was an afterthought, designed as a (inconsistent) convenience function exactly to provide the "saner" alternative you are asking for.