title: Is it safe to push_back an element from the same vector?
body: <pre><code>vector&lt;int&gt; v;
  v.push_back(1);
  v.push_back(v[0]);
  </code></pre>
  
  <p>If the second push_back causes a reallocation, the reference to the first integer in the vector will no longer be valid. So this isn't safe?</p>
  
  <pre><code>vector&lt;int&gt; v;
  v.push_back(1);
  v.reserve(v.size() + 1);
  v.push_back(v[0]);
  </code></pre>
  
  <p>This makes it safe?</p>