Why insert from std::map doesn't want to update? [C++]

c++, dictionary

Solution

If you want to insert the same key with different values, you need `std::multimap` instead.

The `std::map::insert` will not do anything if the key already exists. The `std::map::operator[]` will overwrite the old value.

For STL reference you don`t necesary need the C++ standard itself; something like http://www.cplusplus.com/reference/ will do too.

Problem

I'm trying to insert multiple times this same key into map but with different values. It doesn't work. I know that operator[] does this job, but my question is, if this behaviour of insert is correct? Shouldn't insert() inserts? I wonder what standard says. Unfortunately I don't have it(Standard for C++) so I can't check. Thank you for helpful ansers.

Original source