// String based streams -*- C++ -*- #ifndef _MSTREAM_TCC #define _MSTREAM_TCC 1 template typename basic_arraybuf<_CharT, _Traits, _Alloc>::int_type basic_arraybuf<_CharT, _Traits, _Alloc>:: underflow() { int_type __ret = traits_type::eof(); const bool __testin = this->_M_mode & ios_base::in; if (__testin) { // Update egptr() to match the actual array end. _M_update_egptr(); if (this->gptr() < this->egptr()) __ret = traits_type::to_int_type(*this->gptr()); } return __ret; } template typename basic_arraybuf<_CharT, _Traits, _Alloc>::pos_type basic_arraybuf<_CharT, _Traits, _Alloc>:: seekoff(off_type __off, ios_base::seekdir __way, ios_base::openmode __mode) { pos_type __ret = pos_type(off_type(-1)); // _GLIBCXX_RESOLVE_LIB_DEFECTS // 453. basic_arraybuf::seekoff need not always fail for an empty stream. const char_type* __beg = this->eback(); if (__beg || !__off) { _M_update_egptr(); off_type __newoffi = __off; if (__way == ios_base::cur) { __newoffi += this->gptr() - __beg; } else if (__way == ios_base::end) __newoffi += this->egptr() - __beg; if (__newoffi >= 0 && this->egptr() - __beg >= __newoffi) { this->gbump((__beg + __newoffi) - this->gptr()); __ret = pos_type(__newoffi); } } return __ret; } template typename basic_arraybuf<_CharT, _Traits, _Alloc>::pos_type basic_arraybuf<_CharT, _Traits, _Alloc>:: seekpos(pos_type __sp, ios_base::openmode __mode) { pos_type __ret = pos_type(off_type(-1)); const char_type* __beg = this->eback(); if ((__beg || !off_type(__sp)) && (__testin || __testout)) { _M_update_egptr(); const off_type __pos(__sp); const bool __testpos = (0 <= __pos && __pos <= this->egptr() - __beg); if (__testpos) { if (__testin) this->gbump((__beg + __pos) - this->gptr()); if (__testout) this->pbump((__beg + __pos) - this->pptr()); __ret = __sp; } } return __ret; } template void basic_arraybuf<_CharT, _Traits, _Alloc>:: _M_sync(char_type* __base, __size_type __i, __size_type __o) { const bool __testin = _M_mode & ios_base::in; const bool __testout = _M_mode & ios_base::out; char_type* __endg = __base + _M_array; char_type* __endp = __base + _M_array_size; if (__base != _M_array) { // setbuf: __i == size of buffer area (_M_array.size() == 0). __endg += __i; __i = 0; __endp = __endg; } if (__testin) this->setg(__base, __base + __i, __endg); if (__testout) { this->setp(__base, __endp); this->pbump(__o); // egptr() always tracks the array end. When !__testin, // for the correct functioning of the streambuf inlines // the other get area pointers are identical. if (!__testin) this->setg(__endg, __endg, __endg); } } // Inhibit implicit instantiations for required instantiations, // which are defined via explicit instantiations elsewhere. // NB: This syntax is a GNU extension. #if _GLIBCXX_EXTERN_TEMPLATE extern template class basic_arraybuf; extern template class basic_iarraystream; extern template class basic_oarraystream; extern template class basic_arraystream; #ifdef _GLIBCXX_USE_WCHAR_T extern template class basic_arraybuf; extern template class basic_iarraystream; extern template class basic_oarraystream; extern template class basic_arraystream; #endif #endif #endif