title: Insert or update a map
body: <p>I have a <code>std::map</code>. Given a <code>&lt;key, value&gt;</code> pair, I need to:</p>
  
  <ul>
  <li>Modify the value in the map if the key exists, or</li>
  <li>Insert the  pair into the map if the key does not exist yet.</li>
  </ul>
  
  <p>I'm doing it like this:</p>
  
  <pre><code>if (map.find(key) == map.end()){
      map.insert(std::pair&lt;int, char&gt;(key, value));
  }
  else {
      map[key] = value;
  }
  </code></pre>
  
  <p>Is this way of doing it correct? Also, is there a faster or more idiomatic way to do this?</p>