title: Is shrink_to_fit the proper way of reducing the capacity a `std::vector` to its size?
body: <p>In C++11 <code>shrink_to_fit</code> was introduce to complement certain STL containers (e.g., <code>std::vector</code>, <code>std::deque</code>, <code>std::string</code>). </p>
  
  <p>Synopsizing, its main functionality is to request the container that is associated to, <strong>to reduce its capacity to fit its size</strong>. However, this <strong>request is non-binding</strong>, and the container implementation is free to optimize otherwise and leave the vector with a capacity greater than its size.</p>
  
  <p>Furthermore, in a previous SO question the OP was discouraged from using <code>shrink_to_fit</code> to reduce the capacity of his <code>std::vector</code> to its size. The reasons not to do so are quoted below:</p>
  
  <blockquote>
    <p><em><code>shrink_to_fit</code> does nothing or it gives you cache locality issues and it's O(n) to
    execute (since you have to copy each item to their new, smaller home).
    Usually it's cheaper to leave the slack in memory. <a href="https://stackoverflow.com/users/80754/massa">@Massa</a></em></p>
  </blockquote>
  
  <p>Could someone be so kind as to address the following questions:</p>
  
  <ul>
  <li>Do the arguments in the quotation hold?</li>
  <li><strong>If yes</strong>, what's the proper way of shrinking an STL container's capacity to its size (at least for <code>std::vector</code>).</li>
  <li>And if there's a better way to shrink a container, what's the reason for the existence of <code>shrink_to_fit</code> after-all? </li>
  </ul>