title: change values of multiple elements in std::multimap by key
body: <p>I am using a <code>std::multimap</code> </p>
  
  <pre><code>std::multimap&lt;string,string&gt; map;
  </code></pre>
  
  <p>It contains elements below</p>
  
  <pre><code>1 2  
  2 3
  3 2
  1 2
  1 0
  </code></pre>
  
  <p>I want to replace all 1's and 2's by X. I searched in <em>google</em> for a long time, but didn't get the result. I tried like</p>
  
  <pre><code>for(it=mmap.begin();it!=mmap.end();it++)
  {
     if(it-&gt;first == "1" || it-&gt;first == "2")
     {
       key = it-&gt;second;
       it.erase(it);
       mmap.insert(pair&lt;string,string&gt;("X",key));
     }
  }
  </code></pre>
  
  <p>but ended up in wrong result . I understand the size varies each time and when we insert the element gets inserted at the end which in turn ends the for loop. any other way to come out of this?</p>