title: How is std::getline() equated with bool?
body: <p>I'm a <code>std::getline(...)</code> virgin and having consulted documentation and example at <a href="http://en.cppreference.com/w/cpp/string/basic_string/getline" rel="nofollow">cppreference.com</a>, I'm confused by example code such as this:</p>
  
  <pre><code>#include &lt;sstream&gt;
  #include &lt;string&gt;
  
  int main(int argc, char* argv[])
  {
      std::string line;
      std::ifstream infile("sample.txt");
  
      while (std::getline(infile, line))
      {
          // Do stuff
      }
  
      return 0;
  }
  </code></pre>
  
  <p>...specifically the while statement: <code>while (std::getline(infile, line))</code>.</p>
  
  <p>The noted documentation says the return value of <code>std::getline(std::basic_istream&lt;CharT,Traits&gt;&amp; input, ...)</code> is <code>input</code>, i.e. a reference to the first argument.</p>
  
  <p>How, then, can the return value of <code>getline</code> be used as the while loop's condition, which needs to be of type <code>bool</code>?</p>
  
  <p>Does <code>std::ifstream</code> implement an <code>operator bool()</code>?</p>