#ifndef _SSTREAM_TCC
#define _SSTREAM_TCC 1
#pragma GCC system_header
#include <sstream>
namespace std
{
template <class _CharT, class _Traits, class _Alloc>
typename basic_stringbuf<_CharT, _Traits, _Alloc>::int_type
basic_stringbuf<_CharT, _Traits, _Alloc>::
pbackfail(int_type __c)
{
int_type __ret = traits_type::eof();
if (this->eback() < this->gptr())
{
const bool __testeof = traits_type::eq_int_type(__c, __ret);
if (!__testeof)
{
const bool __testeq = traits_type::eq(traits_type::
to_char_type(__c),
this->gptr()[-1]);
const bool __testout = this->_M_mode & ios_base::out;
if (__testeq || __testout)
{
this->gbump(-1);
if (!__testeq)
*this->gptr() = traits_type::to_char_type(__c);
__ret = __c;
}
}
else
{
this->gbump(-1);
__ret = traits_type::not_eof(__c);
}
}
return __ret;
}
template <class _CharT, class _Traits, class _Alloc>
typename basic_stringbuf<_CharT, _Traits, _Alloc>::int_type
basic_stringbuf<_CharT, _Traits, _Alloc>::
overflow(int_type __c)
{
const bool __testout = this->_M_mode & ios_base::out;
if (__builtin_expect(!__testout, false))
return traits_type::eof();
const bool __testeof = traits_type::eq_int_type(__c, traits_type::eof());
if (__builtin_expect(__testeof, false))
return traits_type::not_eof(__c);
const __size_type __capacity = _M_string.capacity();
const __size_type __max_size = _M_string.max_size();
const bool __testput = this->pptr() < this->epptr();
if (__builtin_expect(!__testput && __capacity == __max_size, false))
return traits_type::eof();
if (!__testput)
{
const __size_type __opt_len = std::max(__size_type(2 * __capacity),
__size_type(512));
const __size_type __len = std::min(__opt_len, __max_size);
__string_type __tmp;
__tmp.reserve(__len);
if (this->pbase())
__tmp.assign(this->pbase(), this->epptr() - this->pbase());
_M_string.swap(__tmp);
_M_sync(const_cast<char_type*>(_M_string.data()),
this->gptr() - this->eback(), this->pptr() - this->pbase());
}
return this->sputc(traits_type::to_char_type(__c));
}
template <class _CharT, class _Traits, class _Alloc>
typename basic_stringbuf<_CharT, _Traits, _Alloc>::int_type
basic_stringbuf<_CharT, _Traits, _Alloc>::
underflow()
{
int_type __ret = traits_type::eof();
const bool __testin = this->_M_mode & ios_base::in;
if (__testin)
{
_M_update_egptr();
if (this->gptr() < this->egptr())
__ret = traits_type::to_int_type(*this->gptr());
}
return __ret;
}
template <class _CharT, class _Traits, class _Alloc>
typename basic_stringbuf<_CharT, _Traits, _Alloc>::pos_type
basic_stringbuf<_CharT, _Traits, _Alloc>::
seekoff(off_type __off, ios_base::seekdir __way, ios_base::openmode __mode)
{
pos_type __ret = pos_type(off_type(-1));
bool __testin = (ios_base::in & this->_M_mode & __mode) != 0;
bool __testout = (ios_base::out & this->_M_mode & __mode) != 0;
const bool __testboth = __testin && __testout && __way != ios_base::cur;
__testin &= !(__mode & ios_base::out);
__testout &= !(__mode & ios_base::in);
const char_type* __beg = __testin ? this->eback() : this->pbase();
if ((__beg || !__off) && (__testin || __testout || __testboth))
{
_M_update_egptr();
off_type __newoffi = __off;
off_type __newoffo = __newoffi;
if (__way == ios_base::cur)
{
__newoffi += this->gptr() - __beg;
__newoffo += this->pptr() - __beg;
}
else if (__way == ios_base::end)
__newoffo = __newoffi += this->egptr() - __beg;
if ((__testin || __testboth)
&& __newoffi >= 0
&& this->egptr() - __beg >= __newoffi)
{
this->gbump((__beg + __newoffi) - this->gptr());
__ret = pos_type(__newoffi);
}
if ((__testout || __testboth)
&& __newoffo >= 0
&& this->egptr() - __beg >= __newoffo)
{
this->pbump((__beg + __newoffo) - this->pptr());
__ret = pos_type(__newoffo);
}
}
return __ret;
}
template <class _CharT, class _Traits, class _Alloc>
typename basic_stringbuf<_CharT, _Traits, _Alloc>::pos_type
basic_stringbuf<_CharT, _Traits, _Alloc>::
seekpos(pos_type __sp, ios_base::openmode __mode)
{
pos_type __ret = pos_type(off_type(-1));
const bool __testin = (ios_base::in & this->_M_mode & __mode) != 0;
const bool __testout = (ios_base::out & this->_M_mode & __mode) != 0;
const char_type* __beg = __testin ? this->eback() : this->pbase();
if (__beg && (__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;
}
#if _GLIBCXX_EXTERN_TEMPLATE
extern template class basic_stringbuf<char>;
extern template class basic_istringstream<char>;
extern template class basic_ostringstream<char>;
extern template class basic_stringstream<char>;
#ifdef _GLIBCXX_USE_WCHAR_T
extern template class basic_stringbuf<wchar_t>;
extern template class basic_istringstream<wchar_t>;
extern template class basic_ostringstream<wchar_t>;
extern template class basic_stringstream<wchar_t>;
#endif
#endif
}
#endif