title: Detect when at the end of a stringstream
body: <p>I am trying to write a function which will detect when I'm almost at the end of a stringstream, but it doesn't seem to work. </p>
  
  <p>Here's some code:</p>
  
  <pre><code>std::string path(1.2.3);
  int number;
  std::stringstream ss(path);
  while (!ss.eof()) {
      if (ss.peek() != '.') {
          ss &gt;&gt; number;
          if (ss.tellg() == path.length()) {
              std::cout &lt;&lt; "Last one: " &lt;&lt; number;
          } else {
              std::cout &lt;&lt; number;
          }
      } else { ss.get(); }
  }
  </code></pre>
  
  <p>I tried using ss.tellg() == path.length(), but that doesn't work. Does somebody have an alternative?</p>