title: How to merge two maps in C++ such that the values of the same keys are added, otherwise created?
body: <p>I think the title is pretty clear, this is an example of what I want to achieve it without having to iterate over the keys and add them manually, I was wondering if there exist a faster solution ( some function or a technique... )</p>
  
  <p>Example :</p>
  
  <pre><code>std::map&lt;int,int&gt; a, b, c;
  a[0] = 2;
  a[2] = 5;
  b[0] = 6;
  b[1] = 1;
  </code></pre>
  
  <p>and the result is a map c that contains :</p>
  
  <pre><code>std::cout &lt;&lt; c[0] &lt;&lt; std::endl; // prints 8
  std::cout &lt;&lt; c[1] &lt;&lt; std::endl; // prints 1
  std::cout &lt;&lt; c[2] &lt;&lt; std::endl; // prints 5
  </code></pre>
  
  <p>in brief : </p>
  
  <pre><code>if key exists : add the values
  else create it with the current value
  </code></pre>
  
  <p>Thank you in advance !</p>