简体   繁体   中英

understanding equality from istream_iterator

Can someone please explain why this istream_iterator code.

// code extract from SGI STL istream_iterator class
bool _M_equal(const istream_iterator& __x) const {
   return (_M_ok == __x.M_ok) && (!_M_ok || _M_stream == __x._M_stream);
}

works and is not just written as

bool _M_equal(const istream_iterator& __x) const {
   return (_M_ok == __x.M_ok) && (_M_stream == __x._M_stream);
}

I don't understanding the reason for including !_M_ok. Thanks in advance.

_M_stream == __x._M_stream具有未定义的行为,如果_M_ok__x._M_ok为false。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM