title: Concatenating two std::vector -- which method is more efficient and how/why?
body: <p>Consider the following scenario:</p>
  
  <pre><code>std::vector&lt;int&gt; A;
  std::vector&lt;int&gt; B;
  std::vector&lt;int&gt; AB;
  </code></pre>
  
  <p>I want <code>AB</code> to have contents of <code>A</code> and then the contents of <code>B</code> in the same order.</p>
  
  <p><strong>Approach 1:</strong></p>
  
  <pre><code>AB.reserve( A.size() + B.size() ); // preallocate memory
  AB.insert( AB.end(), A.begin(), A.end() );
  AB.insert( AB.end(), B.begin(), B.end() );
  </code></pre>
  
  <p><strong>Approach 2:</strong></p>
  
  <pre><code>std::vector&lt;int&gt; AB ( A.begin(), A.end() ); // calling constructor
  AB.insert ( AB.end(), B.begin(), B.end() );
  </code></pre>
  
  <p>Which one of the above methods is more efficient? Why?
  Is there a different method that is more efficient?</p>