Insertion and Deletion

In associative containers, values are inserted and deleted based on the keys they have.

The insertion (insert and emplace) and deletion (erase) of elements in associative containers are similar to the rules of a std::vector. For associative container which can have a key only once, the insertion fails if the key is already in the container. Additionally, ordered associative containers support a special function ordAssCont.erase(key), which removes all pairs with the key and returns their number. See the usage of the function.

Get hands-on with 1000+ tech skills courses.