title: Best way of obtaining a key when a value is known in a map
body: <p>Suppose I have a map as such</p>
  
  <pre><code>std::map&lt;std::string,in&gt; mp;
  mp["KeyA"] = 1;
  mp["KeyB"] = 2;
  mp["KeyD"] = 3;
  mp["KeyF"] = 4;
  </code></pre>
  
  <p>Now I need to obtain the key when I have a value known for instance if I have 1 I want to obtain KeyA. My only thought is that I will need to iterate through the whole map and once I find a value then return the key as such. For example the psudocode explains my approach.</p>
  
  <pre><code>for(std::map&lt;std::string,in&gt;::iterator it = mp.begin();i&lt;mp.end;++i)
  {
    if(it-&gt;second == somevalue)
    {
       return it-&gt;first;
    }
  } 
  </code></pre>
  
  <p>I wanted to know if there was a quicker or a better way to accomplish this</p>