3 ms·
Lookup is map.at() (throws on invalid element), you can use map.contains() since c++20 or map.find()!=map.end() to see if the element exists beforehand. operat
by lionkor 4y ago
Lookup is map.at() (throws on invalid element), you can use map.contains() since c++20 or map.find()!=map.end() to see if the element exists beforehand.
operator[] does more than lookup, but there are other functions for the other stuff. It should be pretty clear...?
- colonwqbang 4y agoThings can be clear while still being unintuitive :) Comparing to other languages I know, I couldn't think of another where collection[key] denotes insertion.