title: Why can't I return std::getline's as-if-boolean result?
body: <p>A standard idiom is</p>
  <pre><code>while(std::getline(ifstream, str))
      ...
  </code></pre>
  <p>So if that works, why can't I say</p>
  <pre><code>bool getval(std::string &amp;val)
  {
      ...
  
      std::ifstream infile(filename);
  
      ...
  
      return std::getline(infile, val);
  }
  </code></pre>
  <p>g++ says &quot;<code>cannot convert 'std::basic_istream&lt;char&gt;' to 'bool' in return</code>&quot;.</p>
  <p>Is the Boolean context of a <code>return</code> statement in a <code>bool</code>-valued function somehow different from the Boolean context of <code>while()</code>, such that the <a href="https://stackoverflow.com/questions/51128037">magic conversion</a> that <code>std::basic_istream</code> performs in one context doesn't work in the other?</p>
  <hr />
  <p>Addendum: There's apparently some version and perhaps language standard dependency here.  I got the aforementioned error with g++ 8.3.0.  But I don't get it with gcc 4.6.3, or LLVM (clang) 9.0.0.</p>