diff options
| author | Alexander Kabaev <kan@FreeBSD.org> | 2002-09-01 20:39:13 +0000 |
|---|---|---|
| committer | Alexander Kabaev <kan@FreeBSD.org> | 2002-09-01 20:39:13 +0000 |
| commit | ca6500fcd0812d2b2da8a62d52b3613b4cbab12a (patch) | |
| tree | f69812e8f56ae46c848e604412b0729b776c7756 /contrib/libstdc++/include/bits/streambuf_iterator.h | |
| parent | bb3c979bf518abbe971bd277250c68a3ec567b59 (diff) | |
Notes
Diffstat (limited to 'contrib/libstdc++/include/bits/streambuf_iterator.h')
| -rw-r--r-- | contrib/libstdc++/include/bits/streambuf_iterator.h | 29 |
1 files changed, 17 insertions, 12 deletions
diff --git a/contrib/libstdc++/include/bits/streambuf_iterator.h b/contrib/libstdc++/include/bits/streambuf_iterator.h index 659caecb2aff2..152df9c6e4b99 100644 --- a/contrib/libstdc++/include/bits/streambuf_iterator.h +++ b/contrib/libstdc++/include/bits/streambuf_iterator.h @@ -69,13 +69,13 @@ namespace std public: istreambuf_iterator() throw() - : _M_sbuf(0), _M_c(-2) { } + : _M_sbuf(0), _M_c(traits_type::eof()) { } istreambuf_iterator(istream_type& __s) throw() - : _M_sbuf(__s.rdbuf()), _M_c(-2) { } + : _M_sbuf(__s.rdbuf()), _M_c(traits_type::eof()) { } istreambuf_iterator(streambuf_type* __s) throw() - : _M_sbuf(__s), _M_c(-2) { } + : _M_sbuf(__s), _M_c(traits_type::eof()) { } // NB: The result of operator*() on an end of stream is undefined. char_type @@ -85,21 +85,25 @@ namespace std istreambuf_iterator& operator++() { - if (_M_sbuf && _M_sbuf->sbumpc() == traits_type::eof()) + const int_type __eof = traits_type::eof(); + if (_M_sbuf && traits_type::eq_int_type(_M_sbuf->sbumpc(), __eof)) _M_sbuf = 0; else - _M_c = -2; + _M_c = __eof; return *this; } istreambuf_iterator operator++(int) { + const int_type __eof = traits_type::eof(); istreambuf_iterator __old = *this; - if (_M_sbuf && (__old._M_c = _M_sbuf->sbumpc()) == traits_type::eof()) + if (_M_sbuf + && traits_type::eq_int_type((__old._M_c = _M_sbuf->sbumpc()), + __eof)) _M_sbuf = 0; else - _M_c = -2; + _M_c = __eof; return __old; } @@ -110,8 +114,8 @@ namespace std equal(const istreambuf_iterator& __b) const { const int_type __eof = traits_type::eof(); - bool __thiseof = _M_get() == __eof; - bool __beof = __b._M_get() == __eof; + bool __thiseof = traits_type::eq_int_type(_M_get(), __eof); + bool __beof = traits_type::eq_int_type(__b._M_get(), __eof); return (__thiseof && __beof || (!__thiseof && !__beof)); } #endif @@ -120,13 +124,14 @@ namespace std int_type _M_get() const { - int_type __ret = traits_type::eof(); + const int_type __eof = traits_type::eof(); + int_type __ret = __eof; if (_M_sbuf) { - if (_M_c != static_cast<int_type>(-2)) + if (!traits_type::eq_int_type(_M_c, __eof)) __ret = _M_c; else - if ((__ret = _M_sbuf->sgetc()) == traits_type::eof()) + if (traits_type::eq_int_type((__ret = _M_sbuf->sgetc()), __eof)) _M_sbuf = 0; } return __ret; |
