title: std::strings's capacity(), reserve() & resize() functions
body: <p>I wan to use std::string simply to create a dynamic buffer and than iterate through it using an index. Is resize() the only function to actually allocate the buffer?</p>
  
  <p>I tried reserve() but when I try to access the string via index it asserts. Also when the string's default capacity seems to be 15 bytes (in my case) but if I still can't access it as <code>my_string[1]</code>.</p>
  
  <p>So the capacity of the string is not the actual buffer? Also reserve() also does't allocate the actual buffer?</p>
  
  <pre><code>string my_string;
  
  // I want my string to have 20 bytes long buffer
  my_string.reserve( 20 );
  
  int i = 0;
  
  for ( parsing_something_else_loop )
  {
      char ch = &lt;business_logic&gt;;
  
      // store the character in 
      my_string[i++] = ch; // this crashes
  }
  </code></pre>
  
  <p>If I do resize() instead of reserve() than it works fine. How is it that the string has the capacity but can't really access it with []? Isn't that the point to reserve() size so you can access it?</p>
  
  <p><strong>Add-on</strong>
  In response to the answers, I would like to ask stl folks, Why would anybody use reserve() when resize() does exactly the same and it also initialize the string? I have to say I don't appreciate the performance argument in this case that much. All that resize() does additional to what reserve() does is that it merely initialize the buffer which we know is always nice to do anyways. Can we vote reserve() off the island?</p>