title: Do STL maps initialize primitive types on insert?
body: <p>I have a <code>std::map</code> like this:</p>
  
  <pre><code>map&lt;wstring,int&gt; Scores;
  </code></pre>
  
  <p>It stores names of players and scores. When someone gets a score I would simply do:</p>
  
  <pre><code>Scores[wstrPlayerName]++;
  </code></pre>
  
  <p>When there is no element in the map with the key <code>wstrPlayerName</code> it will create one, but does it initialize to zero or null before the increment or is it left undefined?</p>
  
  <p>Should I test if the element exists every time before increment?</p>
  
  <p>I just wondered because I thought primitive-type things are always undefined when created.</p>
  
  <p>If I write something like:</p>
  
  <pre><code>int i;
  i++;
  </code></pre>
  
  <p>The compiler warns me that i is undefined and when I run the program it is usually not zero.</p>