-namespace std {
-
- template<typename _CharT, typename _Traits>
- basic_streambuf<_CharT, _Traits>::int_type
- basic_streambuf<_CharT, _Traits>::
- sbumpc()
- {
- int_type __ret;
- if (_M_in_cur && _M_in_cur < _M_in_end)
- {
- char_type __c = *gptr();
- ++_M_in_cur;
- if (_M_buf_unified && _M_mode & ios_base::out)
- ++_M_out_cur;
- __ret = traits_type::to_int_type(__c);
- }
- else
- __ret = this->uflow();
- return __ret;
- }
-
- template<typename _CharT, typename _Traits>
- basic_streambuf<_CharT, _Traits>::int_type
- basic_streambuf<_CharT, _Traits>::
- sputbackc(char_type __c)
- {
- int_type __ret;
- bool __testpos = _M_in_cur && _M_in_beg < _M_in_cur;
- bool __testne = _M_in_cur && !traits_type::eq(__c, this->gptr()[-1]);
- if (!__testpos || __testne)
- __ret = pbackfail(traits_type::to_int_type(__c));
- else
- {
- --_M_in_cur;
- if (_M_buf_unified && _M_mode & ios_base::out)
- --_M_out_cur;
- __ret = traits_type::to_int_type(*this->gptr());
- }
- return __ret;
- }
-
- template<typename _CharT, typename _Traits>
- basic_streambuf<_CharT, _Traits>::int_type
- basic_streambuf<_CharT, _Traits>::
- sungetc()
- {
- int_type __ret;
- if (_M_in_cur && _M_in_beg < _M_in_cur)
- {
- --_M_in_cur;
- if (_M_buf_unified && _M_mode & ios_base::out)
- --_M_out_cur;
- __ret = traits_type::to_int_type(*_M_in_cur);
- }
- else
- __ret = this->pbackfail();
- return __ret;
- }
-
- // Don't test against _M_buf + _M_buf_size, because _M_buf reflects
- // allocated space, and on certain (rare but entirely legal)
- // situations, there will be no allocated space yet the internal
- // buffers will still be valid. (This happens if setp is used to set
- // the internal buffer to say some externally-allocated sequence.)
- template<typename _CharT, typename _Traits>
- basic_streambuf<_CharT, _Traits>::int_type
- basic_streambuf<_CharT, _Traits>::
- sputc(char_type __c)
- {
- int_type __ret;
-
- if (_M_out_cur && _M_out_cur < _M_out_beg + _M_buf_size)
- {
- *_M_out_cur = __c;
- _M_out_cur_move(1);
- __ret = traits_type::to_int_type(__c);
- }
- else
- __ret = this->overflow(traits_type::to_int_type(__c));
- return __ret;
- }