title: What's the fastest way to reinitialize a vector?
body: <p>What is the fastest way to reset all values for a large vector to its default values?</p>
  
  <pre><code>struct foo
  {
    int id;
    float score;
  };
  
  std::vector&lt;foo&gt; large_vector(10000000);
  </code></pre>
  
  <p>The simplest way would be to create a new vector, but I guess it takes more time to reallocate memory than to reinitialize an existing one?</p>
  
  <p>I have to iterate over the vector to collect non-zero scores (could be thousands or millions) before resetting it. Should I reset the structs one by one in this loop?</p>
  
  <p><strong>Edit:</strong></p>
  
  <p>The vector size is fixed and 'default value' means 0 for every struct member (all floats and ints).</p>