title: How to release the unused capacity of a string
body: <p>I am dealing with a lot of strings in my program.
  These string data don't change through out the whole life time after they being read into my program.</p>
  
  <p>But since the C++ string reserves capacity, they waste a lot of space that won't be used for sure.
  I tried to release those spaces, but it didn't work.</p>
  
  <p>The following is the simple code that I tried:</p>
  
  <pre><code>string temp = "1234567890123456";
  string str;
  
  cout &lt;&lt; str.capacity() &lt;&lt; endl;   
  
  str.reserve(16);    
  cout &lt;&lt; str.capacity() &lt;&lt; endl;     
  // capacity is 31 on my computer    
  
  str += temp;    
  cout &lt;&lt; str.capacity() &lt;&lt; endl;    
  
  str.reserve(16);    
  cout &lt;&lt; str.capacity() &lt;&lt; endl;     
  // can't release. The capacity is still 31.
  </code></pre>
  
  <p>(The compiler is Visual C++)</p>
  
  <p>How could I release it?</p>