title: How to remove multiple items from unordered map while iterating over it?
body: <p>Please consider the following situation:</p>
  
  <pre><code>using namespace std;
  unordered_map&lt;int, vector&lt;A&gt;&gt; elements;
  </code></pre>
  
  <p>Now I'm iterating over this unordered map:</p>
  
  <pre><code>for (auto it = elements.begin(); it != elements.end(); ++it)
  </code></pre>
  
  <p>Inside the loop, I'm forming clusters out of several elements of <code>elements</code> (the current one that <code>it</code> points to and some more, not necessarily those next in line!). Because each element can be only part of one cluster, I'd like to remove those from the map and then continue with the next element (i.e., build the next cluster).</p>
  
  <p>How can I do this and still continue the iteration at the correct position?</p>