samedi 30 mars 2019

Do we need to check if an unordered_set contains an element before trying to erase it?

Say I have a set:

std::unordered_set<int> mints;

Then I do:

mints.erase(foo);

But mints doesn't contain foo! Is it guaranteed that nothing bad will happen, and that erase will simply just return 0 ?

Aucun commentaire:

Enregistrer un commentaire