title: Properly overloading >> Operator in C++
body: <p>I couldn't find a proper example of how to do it properly.</p>
  
  <p>The following code is written in the FAQ.</p>
  
  <pre><code>std::istream&amp; operator&gt;&gt;(std::istream&amp; is, T&amp; obj)
  {
    // read obj from stream
  
  if( /* no valid object of T found in stream */ )
      is.setstate(std::ios::failbit);
  
  return is;
  }
  </code></pre>
  
  <p>How do I check if "no valid object of T found in stream" ?</p>