title: What happens when we do cout<<string?
body: <p>Consider we have declared a string like this: <code>string x;</code> and a vector of chars like this: <code>vector&lt;char&gt; x_vec;</code>
  I was thinking if there is any advantage of doing</p>
  
  <pre><code>cout&lt;&lt;x;
  </code></pre>
  
  <p>Over</p>
  
  <pre><code>for(int i=0;i&lt;x.length();i++)
        cout&lt;&lt;x[i];
  </code></pre>
  
  <p>Or</p>
  
  <pre><code>for(int i=0;i&lt;x_vec.size();i++)
        cout&lt;&lt;x_vec[i];
  </code></pre>
  
  <p>in <em>performance</em>? My point is because very often we get to the point where we must choose between <code>string</code>s and <code>vector</code>s of chars. Is the first example actually treated or approached by the program differently from the other examples?</p>