title: Is the following std::vector code valid?
body: <pre><code>std::vector&lt;Foo&gt; vec;
  Foo foo(...);
  
  assert(vec.size() == 0);
  vec.reserve(100); // I've reserved 100 elems
  vec[50] = foo; // but I haven't initialized any of them
  // so am I assigning into uninitialized memory?
  </code></pre>
  
  <p>Is the above code safe? </p>