Found that std::unordered_set
and std::unordered_map
has range-based erase(first, last)
which in my opinion is another nice way to shoot yourself in leg.
Maybe somebody know any real use case for such functionality?
Or this may be considered as bad design?
I think it is to provide compatibility with regular map and set.
But I still think it's useful in principle. If a range of values is retired, you want to remove them from the collection. But the normal use case is looking up (a million times more common than insert/delete) and it is not traversed, so the unordered version is good.
How can it shoot you? It's no different from erasing each one in a loop. Ah, the plain start,end range forward traversal won't work, so you think the supplied function doesn't do what it takes to get it right, but does the same forward-range traversal that would work on a map but break on an unordered_map?
Gee, does it?
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