How would I erase all elements from an std::multimap who have a key less than or equal to 20?
I know how to erase, I don't know how to pass in the condition "key less than 20".
The next code should work:
std::multimap<int, int> M;
// initialize M here
auto it = M.upper_bound(20);
M.erase(M.begin(), it);
Just use upper_bound and then erase.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With