Is it possible to remove elements from std :: unordered_set through bucket iterators?

As in the question, can you remove an element from std::unordered_set using the bucket iterator ( local_iterator )? I see two possible solutions:

  • Since erase () accepts only global iterator s, is there equivalent functionality for local_iterator ?
  • Is it possible to get an equivalent global iterator for a local_iterator ?

If this is not possible, please clarify why this is not so.

+7
c ++ c ++ 11 unordered-set
source share
1 answer

The obvious answer is no, as in an interface that supports this. There is also no way to get to a iterator from a local_iterator , for the obvious reason that a local_iterator contains a lot less information. (For most implementations, I suspect that it would be quite simple to implement erase( local_iterator ) , the standard one required it. On the other hand, I can’t think of imaginable use for this, which may be the reason that the standard did not require this.)

+5
source share

All Articles