title: Reading from ifstream won't read whitespace
body: <p>I'm implementing a custom lexer in C++ and when attempting to read in whitespace, the ifstream won't read it out. I'm reading character by character using <code>&gt;&gt;</code>, and all the whitespace is gone. Is there any way to make the ifstream keep all the whitespace and read it out to me? I know that when reading whole strings, the read will stop at whitespace, but I was hoping that by reading character by character, I would avoid this behaviour.</p>
  
  <p>Attempted: <code>.get()</code>, recommended by many answers, but it has the same effect as <code>std::noskipws</code>, that is, I get all the spaces now, but <em>not</em> the new-line character that I need to lex some constructs.</p>
  
  <p>Here's the offending code (extended comments truncated)</p>
  
  <pre><code>while(input &gt;&gt; current) {
      always_next_struct val = always_next_struct(next);
      if (current == L' ' || current == L'\n' || current == L'\t' || current == L'\r') {
          continue;
      }
      if (current == L'/') {
          input &gt;&gt; current;
          if (current == L'/') {
              // explicitly empty while loop
              while(input.get(current) &amp;&amp; current != L'\n');
              continue;
          }
  </code></pre>
  
  <p>I'm breaking on the <code>while</code> line and looking at every value of <code>current</code> as it comes in, and <code>\r</code> or <code>\n</code> are definitely not among them- the input just skips to the next line in the input file.</p>