Why is there no operator [] for std :: multimap?

Why is there no operator [] for std :: multimap?

In errors with multimap (the key type is std :: string) , people say: "There is no point in extracting elements from it - there are several values ​​for each index." This makes sense to me, and that is why there is equal_mode.

So why did they decide not to add the [] operator for the multimap, then?

I feel that things like myMultiMap[key] = value will be difficult to handle, but I'm really not sure about that.

+5
source share
1 answer

This may be due to ambiguity, since multiMap [key] can represent many elements depending on the number of inserts with the same key.

0
source

Source: https://habr.com/ru/post/1210648/


All Articles