title: STL vectors with uninitialized storage?
body: <p>I'm writing an inner loop that needs to place <code>struct</code>s in contiguous storage.  I don't know how many of these <code>struct</code>s there will be ahead of time.  My problem is that STL's <code>vector</code> initializes its values to 0, so no matter what I do, I incur the cost of the initialization plus the cost of setting the <code>struct</code>'s members to their values.</p>
  
  <p>Is there any way to prevent the initialization, or is there an STL-like container out there with resizeable contiguous storage and uninitialized elements?</p>
  
  <p>(I'm certain that this part of the code needs to be optimized, and I'm certain that the initialization is a significant cost.)</p>
  
  <p>Also, see my comments below for a clarification about when the initialization occurs.</p>
  
  <p>SOME CODE:</p>
  
  <pre><code>void GetsCalledALot(int* data1, int* data2, int count) {
      int mvSize = memberVector.size()
      memberVector.resize(mvSize + count); // causes 0-initialization
  
      for (int i = 0; i &lt; count; ++i) {
          memberVector[mvSize + i].d1 = data1[i];
          memberVector[mvSize + i].d2 = data2[i];
      }
  }
  </code></pre>