Explicit do sgetc from associated streambuf. Avoid debug-dependent sgetc (within _M_at_eof()):
__glibcxx_requires_cond(!_M_at_eof(), _M_message(__gnu_debug::__msg_inc_istreambuf) ._M_iterator(*this)); Increment operators not require not-eof precoditions. Don't unlink associated streambuf if eof detected (in _M_get). Clean logic in postfix increment operator. --- libstdc++-v3/include/bits/streambuf_iterator.h | 24 +++++------------------- 1 file changed, 5 insertions(+), 19 deletions(-) diff --git a/libstdc++-v3/include/bits/streambuf_iterator.h b/libstdc++-v3/include/bits/streambuf_iterator.h index 2230e94..cff3b69 100644 --- a/libstdc++-v3/include/bits/streambuf_iterator.h +++ b/libstdc++-v3/include/bits/streambuf_iterator.h @@ -136,9 +136,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION istreambuf_iterator& operator++() { - __glibcxx_requires_cond(!_M_at_eof(), - _M_message(__gnu_debug::__msg_inc_istreambuf) - ._M_iterator(*this)); if (_M_sbuf) { _M_sbuf->sbumpc(); @@ -151,14 +148,12 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION istreambuf_iterator operator++(int) { - __glibcxx_requires_cond(!_M_at_eof(), - _M_message(__gnu_debug::__msg_inc_istreambuf) - ._M_iterator(*this)); + _M_get(); istreambuf_iterator __old = *this; if (_M_sbuf) { - __old._M_c = _M_sbuf->sbumpc(); + _M_sbuf->sbumpc(); _M_c = traits_type::eof(); } return __old; @@ -177,18 +172,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION _M_get() const { const int_type __eof = traits_type::eof(); - int_type __ret = __eof; - if (_M_sbuf) - { - if (!traits_type::eq_int_type(_M_c, __eof)) - __ret = _M_c; - else if (!traits_type::eq_int_type((__ret = _M_sbuf->sgetc()), - __eof)) - _M_c = __ret; - else - _M_sbuf = 0; - } - return __ret; + if (_M_sbuf && traits_type::eq_int_type(_M_c, __eof)) + _M_c = _M_sbuf->sgetc(); + return _M_c; } bool -- 2.10.1