title: Why does c++ initialise a std::vector with zeros, but not a std::array?
body: <p>Isn't it a waste of time to initialize a vector with zeros, when you don't want it?</p>
  
  <p>I try this code:</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;vector&gt;
  #include &lt;array&gt;
  
  #define SIZE 10
  
  int main()
  {
  #ifdef VECTOR
  
    std::vector&lt;unsigned&gt; arr(SIZE);
  
  #else
  
    std::array&lt;unsigned, SIZE&gt; arr;
  
  #endif // VECTOR
  
    for (unsigned n : arr)
      printf("%i ", n);
    printf("\n");
  
    return 0;
  }
  </code></pre>
  
  <p>and I get the output:</p>
  
  <p>with vector</p>
  
  <pre><code>$ g++ -std=c++11 -D VECTOR test.cpp -o test &amp;&amp; ./test 
  0 0 0 0 0 0 0 0 0 0 
  </code></pre>
  
  <p>with an array</p>
  
  <pre><code>g++ -std=c++11  test.cpp -o test &amp;&amp; ./test 
  -129655920 32766 4196167 0 2 0 4196349 0 1136 0 
  </code></pre>
  
  <p>And I also try with clang++</p>
  
  <p>So why zeros? And by the way, could I declare a vector without initializing it?</p>