title: How can an object reference work as a boolean expression?
body: <p>I'm reading file by file stream in the C++ Standard Library:</p>
  
  <pre><code>std::ifstream infile(path.c_str());
  if (!infile.is_open())
  {
      return -1;
  }
  std::string line;
  while (std::getline(infile, line))
  {
      std::cout &lt;&lt; line &lt;&lt; std::endl;
  }
  </code></pre>
  
  <p>This works. What impressed me is that <code>std::getline</code> actually returns an <code>std::ifstream&amp;</code>; how can a reference to object work as a boolean expression? Second, if I write it this way:</p>
  
  <pre><code>while (NULL != std::getline(infile, line))
  </code></pre>
  
  <p>this also works. I don't get it why a reference here works like a pointer.</p>