37 #define _OSTREAM_TCC 1
39 #pragma GCC system_header
41 #include <cxxabi-forced.h>
43 _GLIBCXX_BEGIN_NAMESPACE(std)
45 template<typename _CharT, typename _Traits>
46 basic_ostream<_CharT, _Traits>::sentry::
48 : _M_ok(false), _M_os(__os)
51 if (__os.tie() && __os.good())
57 __os.setstate(ios_base::failbit);
60 template<
typename _CharT,
typename _Traits>
61 template<
typename _ValueT>
69 ios_base::iostate __err = ios_base::iostate(ios_base::goodbit);
73 if (__np.
put(*
this, *
this, this->fill(), __v).failed())
74 __err |= ios_base::badbit;
78 this->_M_setstate(ios_base::badbit);
79 __throw_exception_again;
82 { this->_M_setstate(ios_base::badbit); }
84 this->setstate(__err);
89 template<
typename _CharT,
typename _Traits>
90 basic_ostream<_CharT, _Traits>&
96 const ios_base::fmtflags __fmt = this->flags() & ios_base::basefield;
98 return _M_insert(static_cast<long>(static_cast<unsigned short>(__n)));
100 return _M_insert(static_cast<long>(__n));
103 template<
typename _CharT,
typename _Traits>
110 const ios_base::fmtflags __fmt = this->flags() & ios_base::basefield;
112 return _M_insert(static_cast<long>(static_cast<unsigned int>(__n)));
114 return _M_insert(static_cast<long>(__n));
117 template<
typename _CharT,
typename _Traits>
122 ios_base::iostate __err = ios_base::iostate(ios_base::goodbit);
124 if (__cerb && __sbin)
128 if (!__copy_streambufs(__sbin, this->rdbuf()))
129 __err |= ios_base::failbit;
133 this->_M_setstate(ios_base::badbit);
134 __throw_exception_again;
137 { this->_M_setstate(ios_base::failbit); }
140 __err |= ios_base::badbit;
142 this->setstate(__err);
146 template<
typename _CharT,
typename _Traits>
160 ios_base::iostate __err = ios_base::iostate(ios_base::goodbit);
163 const int_type __put = this->rdbuf()->sputc(__c);
164 if (traits_type::eq_int_type(__put, traits_type::eof()))
165 __err |= ios_base::badbit;
169 this->_M_setstate(ios_base::badbit);
170 __throw_exception_again;
173 { this->_M_setstate(ios_base::badbit); }
175 this->setstate(__err);
180 template<
typename _CharT,
typename _Traits>
196 { _M_write(__s, __n); }
199 this->_M_setstate(ios_base::badbit);
200 __throw_exception_again;
203 { this->_M_setstate(ios_base::badbit); }
208 template<
typename _CharT,
typename _Traits>
216 ios_base::iostate __err = ios_base::iostate(ios_base::goodbit);
219 if (this->rdbuf() && this->rdbuf()->pubsync() == -1)
220 __err |= ios_base::badbit;
224 this->_M_setstate(ios_base::badbit);
225 __throw_exception_again;
228 { this->_M_setstate(ios_base::badbit); }
230 this->setstate(__err);
234 template<
typename _CharT,
typename _Traits>
235 typename basic_ostream<_CharT, _Traits>::pos_type
239 pos_type __ret = pos_type(-1);
243 __ret = this->rdbuf()->pubseekoff(0, ios_base::cur, ios_base::out);
247 this->_M_setstate(ios_base::badbit);
248 __throw_exception_again;
251 { this->_M_setstate(ios_base::badbit); }
255 template<
typename _CharT,
typename _Traits>
260 ios_base::iostate __err = ios_base::iostate(ios_base::goodbit);
267 const pos_type __p = this->rdbuf()->pubseekpos(__pos,
271 if (__p == pos_type(off_type(-1)))
272 __err |= ios_base::failbit;
277 this->_M_setstate(ios_base::badbit);
278 __throw_exception_again;
281 { this->_M_setstate(ios_base::badbit); }
283 this->setstate(__err);
287 template<
typename _CharT,
typename _Traits>
290 seekp(off_type __off, ios_base::seekdir __dir)
292 ios_base::iostate __err = ios_base::iostate(ios_base::goodbit);
299 const pos_type __p = this->rdbuf()->pubseekoff(__off, __dir,
303 if (__p == pos_type(off_type(-1)))
304 __err |= ios_base::failbit;
309 this->_M_setstate(ios_base::badbit);
310 __throw_exception_again;
313 { this->_M_setstate(ios_base::badbit); }
315 this->setstate(__err);
319 template<
typename _CharT,
typename _Traits>
321 operator<<(basic_ostream<_CharT, _Traits>& __out,
const char* __s)
335 __ptr_guard (_CharT *__ip): __p(__ip) { }
336 ~__ptr_guard() {
delete[] __p; }
337 _CharT* __get() {
return __p; }
338 } __pg (
new _CharT[__clen]);
340 _CharT *__ws = __pg.__get();
341 for (
size_t __i = 0; __i < __clen; ++__i)
342 __ws[__i] = __out.widen(__s[__i]);
343 __ostream_insert(__out, __ws, __clen);
347 __out._M_setstate(ios_base::badbit);
348 __throw_exception_again;
351 { __out._M_setstate(ios_base::badbit); }
359 #if _GLIBCXX_EXTERN_TEMPLATE
360 extern template class basic_ostream<char>;
371 extern template ostream& ostream::_M_insert(
long);
372 extern template ostream& ostream::_M_insert(
unsigned long);
373 extern template ostream& ostream::_M_insert(
bool);
374 #ifdef _GLIBCXX_USE_LONG_LONG
375 extern template ostream& ostream::_M_insert(
long long);
376 extern template ostream& ostream::_M_insert(
unsigned long long);
378 extern template ostream& ostream::_M_insert(
double);
379 extern template ostream& ostream::_M_insert(
long double);
380 extern template ostream& ostream::_M_insert(
const void*);
382 #ifdef _GLIBCXX_USE_WCHAR_T
383 extern template class basic_ostream<wchar_t>;
392 extern template wostream& wostream::_M_insert(
long);
393 extern template wostream& wostream::_M_insert(
unsigned long);
394 extern template wostream& wostream::_M_insert(
bool);
395 #ifdef _GLIBCXX_USE_LONG_LONG
396 extern template wostream& wostream::_M_insert(
long long);
397 extern template wostream& wostream::_M_insert(
unsigned long long);
399 extern template wostream& wostream::_M_insert(
double);
400 extern template wostream& wostream::_M_insert(
long double);
401 extern template wostream& wostream::_M_insert(
const void*);
405 _GLIBCXX_END_NAMESPACE
basic_ostream< _CharT, _Traits > & flush(basic_ostream< _CharT, _Traits > &__os)
Flushes the output stream.
Performs setup work for output streams.
ptrdiff_t streamsize
Integral type for I/O operation counts and buffer sizes.
basic_ostream< _CharT, _Traits > & endl(basic_ostream< _CharT, _Traits > &__os)
Write a newline and flush the stream.
void setstate(iostate __state)
Sets additional flags in the error state.
ios_base & hex(ios_base &__base)
Calls base.setf(ios_base::hex, ios_base::basefield).
The actual work of input and output (interface).
iter_type put(iter_type __s, ios_base &__f, char_type __fill, bool __v) const
Numeric formatting.
basic_ostream< _CharT, _Traits > & ends(basic_ostream< _CharT, _Traits > &__os)
Write a null character into the output sequence.
Thrown as part of forced unwinding.A magic placeholder class that can be caught by reference to recog...
basic_ostream< wchar_t > wostream
One of the I/O .
Controlling output.This is the base class for all output streams. It provides text formatting of all ...
basic_ostream< char > ostream
One of the I/O .
ios_base & oct(ios_base &__base)
Calls base.setf(ios_base::oct, ios_base::basefield).
Facet for converting numbers to strings.
std::basic_ostream< _CharT, _Traits > & operator<<(std::basic_ostream< _CharT, _Traits > &__os, const bitset< _Nb > &__x)
Global I/O operators for bitsets.
Basis for explicit traits specializations.