title: Replacing part of std::vector by smaller std::vector
body: <p>I wonder what would be the correct way to replace (overwriting) a part of a given std::vector &quot;input&quot; by another, smaller std::vector?
  I do neet to keep the rest of the original vector unchanged.
  Also I do not need to bother what has been in the original vector and
  I don't need to keep the smaller vector afterwards anymore.</p>
  <p>Say I have this:</p>
  <pre><code>std::vector&lt;int&gt; input = { 0, 0, 1, 1, 2, 22, 3, 33, 99 };
  std::vector&lt;int&gt; a = { 1, 2, 3 };
  std::vector&lt;int&gt; b = { 4, 5, 6, 7, 8 };
  </code></pre>
  <p>And I want to achieve that:</p>
  <pre><code>input = { 1, 2, 3, 4, 5, 6, 7, 8, 99}
  </code></pre>
  <p>What is the right way to do it? I thought of something like</p>
  <pre><code>input.replace(input.beginn(), input.beginn()+a.size(), a);
  // intermediate input would look like that: input = { 1, 2, 3, 1, 2, 22, 3, 33, 99 };
  
  input.replace(input.beginn()+a.size(), input.beginn()+a.size()+b.size(), b);
  </code></pre>
  <p>There should be a standard way to do it, shouldn't it?
  My thoughts on this so far are the following:</p>
  <ul>
  <li><p>I can not use std::vector::assign for it destroys all elements of input</p>
  </li>
  <li><p>std::vector::push_back would not replace but enlarge the input --&gt; not what I want</p>
  </li>
  <li><p>std::vector::insert also creates new elements and enlages the input vector but I know for sure that the vectors a.size() + b.size() &lt;= input.size()</p>
  </li>
  <li><p>std::vector::swap would not work since there is some content of input that needs to remain there ( in the example the last element) also it would not work to add b that way</p>
  </li>
  <li><p>std::vector::emplace also increases the input.size -&gt; seems wrong as well</p>
  </li>
  </ul>
  <p>Also I would prefer if the solution would not waste performance by unnecessary clears or writing back values into the vectors a or b. My vectors will be very large for real and this is about performance in the end.</p>
  <p>Any competent help would be appreciated very much.</p>