title: stringstream code separating words - how does this thing work? code snippet inside
body: <p>i have this code i found to cut a string into words.
  i cant figure out how the while part works. how does it know to extract words without whitespaces to the buf variable?
  it seems the extraction operator (>>) is used both to progress bits into the buffer, and to return true for the loop - i just cant figure out how it knows to cut the words by whitespaces. </p>
  
  <pre><code>string buf; // Have a buffer string
  stringstream ss(str); // Insert the string into a stream
  
  vector&lt;string&gt; tokens; // Create vector to hold our words
  
  while (ss &gt;&gt; buf)
      tokens.push_back(buf);
  </code></pre>