C++ standard vector resize() function
<p>resize() adds/removes elements based on the size given to it. reserve() reserves memory space and it will not reallocate memory. The question I have is whether resize also works the same as in the capacity of the vector will only not increase?</p>

<p>To add, would a combination of:</p>

<pre><code> std::vector&lt;X&gt; vector;
 vector.reserve(5);
 vector.resize(5); 
</code></pre>

<p>make any sense? Is it redundant? The goal here is to be able to overwrite values in the vector without having the vector allocate any extra space.</p>