33 #ifndef _GLIBCXX_OSTREAM 34 #define _GLIBCXX_OSTREAM 1 36 #pragma GCC system_header 41 namespace std _GLIBCXX_VISIBILITY(default)
43 _GLIBCXX_BEGIN_NAMESPACE_VERSION
57 template<
typename _CharT,
typename _Traits>
58 class basic_ostream :
virtual public basic_ios<_CharT, _Traits>
62 typedef _CharT char_type;
63 typedef typename _Traits::int_type int_type;
64 typedef typename _Traits::pos_type pos_type;
65 typedef typename _Traits::off_type off_type;
66 typedef _Traits traits_type;
69 typedef basic_streambuf<_CharT, _Traits> __streambuf_type;
70 typedef basic_ios<_CharT, _Traits> __ios_type;
71 typedef basic_ostream<_CharT, _Traits> __ostream_type;
72 typedef num_put<_CharT, ostreambuf_iterator<_CharT, _Traits> >
74 typedef ctype<_CharT> __ctype_type;
167 {
return _M_insert(__n); }
171 {
return _M_insert(__n); }
175 {
return _M_insert(__n); }
185 return _M_insert(static_cast<unsigned long>(__n));
196 return _M_insert(static_cast<unsigned long>(__n));
199 #ifdef _GLIBCXX_USE_LONG_LONG 202 {
return _M_insert(__n); }
206 {
return _M_insert(__n); }
221 {
return _M_insert(__f); }
228 return _M_insert(static_cast<double>(__f));
233 {
return _M_insert(__f); }
246 {
return _M_insert(__p); }
248 #if __cplusplus >= 201703L 251 {
return *
this <<
"nullptr"; }
254 #if __cplusplus > 202002L 255 __attribute__((__always_inline__))
258 {
return _M_insert(const_cast<const void*>(__p)); }
394 seekp(off_type, ios_base::seekdir);
400 #if __cplusplus >= 201103L 402 basic_ostream(basic_iostream<_CharT, _Traits>&) { }
415 operator=(basic_ostream&& __rhs)
422 swap(basic_ostream& __rhs)
423 { __ios_type::swap(__rhs); }
426 template<
typename _ValueT>
428 _M_insert(_ValueT __v);
438 template <
typename _CharT,
typename _Traits>
460 #pragma GCC diagnostic push 461 #pragma GCC diagnostic ignored "-Wdeprecated-declarations" 475 if (_M_os.rdbuf() && _M_os.rdbuf()->pubsync() == -1)
479 #pragma GCC diagnostic pop 488 #if __cplusplus >= 201103L 491 operator bool()
const 511 template<
typename _CharT,
typename _Traits>
513 operator<<(basic_ostream<_CharT, _Traits>& __out, _CharT __c)
514 {
return __ostream_insert(__out, &__c, 1); }
516 template<
typename _CharT,
typename _Traits>
517 inline basic_ostream<_CharT, _Traits>&
518 operator<<(basic_ostream<_CharT, _Traits>& __out,
char __c)
519 {
return (__out << __out.widen(__c)); }
522 template<
typename _Traits>
523 inline basic_ostream<char, _Traits>&
524 operator<<(basic_ostream<char, _Traits>& __out,
char __c)
525 {
return __ostream_insert(__out, &__c, 1); }
528 template<
typename _Traits>
529 inline basic_ostream<char, _Traits>&
530 operator<<(basic_ostream<char, _Traits>& __out,
signed char __c)
531 {
return (__out << static_cast<char>(__c)); }
533 template<
typename _Traits>
534 inline basic_ostream<char, _Traits>&
535 operator<<(basic_ostream<char, _Traits>& __out,
unsigned char __c)
536 {
return (__out << static_cast<char>(__c)); }
538 #if __cplusplus > 201703L 542 template<
typename _Traits>
543 basic_ostream<char, _Traits>&
544 operator<<(basic_ostream<char, _Traits>&, wchar_t) =
delete;
546 #ifdef _GLIBCXX_USE_CHAR8_T 547 template<
typename _Traits>
548 basic_ostream<char, _Traits>&
549 operator<<(basic_ostream<char, _Traits>&, char8_t) =
delete;
552 template<
typename _Traits>
553 basic_ostream<char, _Traits>&
554 operator<<(basic_ostream<char, _Traits>&, char16_t) =
delete;
556 template<
typename _Traits>
557 basic_ostream<char, _Traits>&
558 operator<<(basic_ostream<char, _Traits>&, char32_t) =
delete;
560 #ifdef _GLIBCXX_USE_WCHAR_T 561 #ifdef _GLIBCXX_USE_CHAR8_T 562 template<
typename _Traits>
563 basic_ostream<wchar_t, _Traits>&
564 operator<<(basic_ostream<wchar_t, _Traits>&, char8_t) =
delete;
565 #endif // _GLIBCXX_USE_CHAR8_T 567 template<
typename _Traits>
568 basic_ostream<wchar_t, _Traits>&
569 operator<<(basic_ostream<wchar_t, _Traits>&, char16_t) =
delete;
571 template<
typename _Traits>
572 basic_ostream<wchar_t, _Traits>&
573 operator<<(basic_ostream<wchar_t, _Traits>&, char32_t) =
delete;
574 #endif // _GLIBCXX_USE_WCHAR_T 592 template<
typename _CharT,
typename _Traits>
593 inline basic_ostream<_CharT, _Traits>&
594 operator<<(basic_ostream<_CharT, _Traits>& __out,
const _CharT* __s)
599 __ostream_insert(__out, __s,
600 static_cast<streamsize>(_Traits::length(__s)));
604 template<
typename _CharT,
typename _Traits>
605 basic_ostream<_CharT, _Traits> &
606 operator<<(basic_ostream<_CharT, _Traits>& __out,
const char* __s);
609 template<
typename _Traits>
610 inline basic_ostream<char, _Traits>&
611 operator<<(basic_ostream<char, _Traits>& __out,
const char* __s)
616 __ostream_insert(__out, __s,
617 static_cast<streamsize>(_Traits::length(__s)));
622 template<
typename _Traits>
623 inline basic_ostream<char, _Traits>&
624 operator<<(basic_ostream<char, _Traits>& __out,
const signed char* __s)
625 {
return (__out << reinterpret_cast<const char*>(__s)); }
627 template<
typename _Traits>
628 inline basic_ostream<char, _Traits> &
629 operator<<(basic_ostream<char, _Traits>& __out,
const unsigned char* __s)
630 {
return (__out << reinterpret_cast<const char*>(__s)); }
632 #if __cplusplus > 201703L 636 template<
typename _Traits>
637 basic_ostream<char, _Traits>&
638 operator<<(basic_ostream<char, _Traits>&,
const wchar_t*) =
delete;
640 #ifdef _GLIBCXX_USE_CHAR8_T 641 template<
typename _Traits>
642 basic_ostream<char, _Traits>&
643 operator<<(basic_ostream<char, _Traits>&,
const char8_t*) =
delete;
644 #endif // _GLIBCXX_USE_CHAR8_T 646 template<
typename _Traits>
647 basic_ostream<char, _Traits>&
648 operator<<(basic_ostream<char, _Traits>&,
const char16_t*) =
delete;
650 template<
typename _Traits>
651 basic_ostream<char, _Traits>&
652 operator<<(basic_ostream<char, _Traits>&,
const char32_t*) =
delete;
654 #ifdef _GLIBCXX_USE_WCHAR_T 655 #ifdef _GLIBCXX_USE_CHAR8_T 656 template<
typename _Traits>
657 basic_ostream<wchar_t, _Traits>&
658 operator<<(basic_ostream<wchar_t, _Traits>&,
const char8_t*) =
delete;
661 template<
typename _Traits>
662 basic_ostream<wchar_t, _Traits>&
663 operator<<(basic_ostream<wchar_t, _Traits>&,
const char16_t*) =
delete;
665 template<
typename _Traits>
666 basic_ostream<wchar_t, _Traits>&
667 operator<<(basic_ostream<wchar_t, _Traits>&,
const char32_t*) =
delete;
668 #endif // _GLIBCXX_USE_WCHAR_T 682 template<
typename _CharT,
typename _Traits>
683 inline basic_ostream<_CharT, _Traits>&
685 {
return flush(__os.put(__os.widen(
'\n'))); }
694 template<
typename _CharT,
typename _Traits>
695 inline basic_ostream<_CharT, _Traits>&
697 {
return __os.put(_CharT()); }
704 template<
typename _CharT,
typename _Traits>
705 inline basic_ostream<_CharT, _Traits>&
707 {
return __os.flush(); }
709 #if __cplusplus >= 201103L 714 #if __cpp_lib_concepts 716 template<
typename _Tp>
717 concept __derived_from_ios_base = is_class_v<_Tp>
718 && (!is_same_v<_Tp, ios_base>)
719 && requires (_Tp* __t, ios_base* __b) { __b = __t; };
721 template<
typename _Os,
typename _Tp>
722 requires __derived_from_ios_base<_Os>
723 && requires (_Os& __os,
const _Tp& __t) { __os << __t; }
724 using __rvalue_stream_insertion_t = _Os&&;
726 template<
typename _Tp>
727 using _Require_derived_from_ios_base
728 = _Require<is_class<_Tp>, __not_<is_same<_Tp, ios_base>>,
729 is_convertible<typename add_pointer<_Tp>::type, ios_base*>>;
731 template<
typename _Os,
typename _Tp,
732 typename = _Require_derived_from_ios_base<_Os>,
734 = decltype(std::declval<_Os&>() << std::declval<const _Tp&>())>
735 using __rvalue_stream_insertion_t = _Os&&;
748 template<
typename _Ostream,
typename _Tp>
749 inline __rvalue_stream_insertion_t<_Ostream, _Tp>
756 #if __cplusplus > 201703L && _GLIBCXX_USE_CXX11_ABI 757 template<
typename _CharT,
typename _Traits>
758 class __syncbuf_base :
public basic_streambuf<_CharT, _Traits>
762 _S_get(basic_streambuf<_CharT, _Traits>* __buf [[maybe_unused]]) noexcept
765 if (
auto __p = dynamic_cast<__syncbuf_base*>(__buf))
766 return &__p->_M_emit_on_sync;
772 __syncbuf_base(basic_streambuf<_CharT, _Traits>* __w =
nullptr)
776 basic_streambuf<_CharT, _Traits>* _M_wrapped =
nullptr;
777 bool _M_emit_on_sync =
false;
778 bool _M_needs_sync =
false;
781 template<
typename _CharT,
typename _Traits>
782 inline basic_ostream<_CharT, _Traits>&
783 emit_on_flush(basic_ostream<_CharT, _Traits>& __os)
785 if (
bool* __flag = __syncbuf_base<_CharT, _Traits>::_S_get(__os.rdbuf()))
790 template<
typename _CharT,
typename _Traits>
791 inline basic_ostream<_CharT, _Traits>&
792 noemit_on_flush(basic_ostream<_CharT, _Traits>& __os)
794 if (
bool* __flag = __syncbuf_base<_CharT, _Traits>::_S_get(__os.rdbuf()))
799 template<
typename _CharT,
typename _Traits>
800 inline basic_ostream<_CharT, _Traits>&
801 flush_emit(basic_ostream<_CharT, _Traits>& __os)
805 ~_Restore() { *_M_flag = _M_prev; }
807 bool _M_prev =
false;
808 bool* _M_flag = &_M_prev;
811 if (
bool* __flag = __syncbuf_base<_CharT, _Traits>::_S_get(__os.rdbuf()))
813 __restore._M_prev = *__flag;
814 __restore._M_flag = __flag;
826 _GLIBCXX_END_NAMESPACE_VERSION
__ostream_type & flush()
Synchronizing the stream buffer.
__ostream_type & put(char_type __c)
Simple insertion.
std::basic_ostream< _CharT, _Traits > & operator<<(std::basic_ostream< _CharT, _Traits > &__os, const bitset< _Nb > &__x)
Global I/O operators for bitsets.
ptrdiff_t streamsize
Integral type for I/O operation counts and buffer sizes.
void setstate(iostate __state)
Sets additional flags in the error state.
__ostream_type & seekp(pos_type)
Changing the current write position.
static const iostate badbit
Indicates a loss of integrity in an input or output sequence (such as an irrecoverable read error fro...
basic_ostream< _CharT, _Traits > & endl(basic_ostream< _CharT, _Traits > &__os)
Write a newline and flush the stream.
The base of the I/O class hierarchy.This class defines everything that can be defined about I/O that ...
pos_type tellp()
Getting the current write position.
void _M_write(const char_type *__s, streamsize __n)
Core write functionality, without sentry.
static const fmtflags unitbuf
Flushes output after each output operation.
basic_ostream(__streambuf_type *__sb)
Base constructor.
__ostream_type & write(const char_type *__s, streamsize __n)
Character string insertion.
__ostream_type & operator<<(__ostream_type &(*__pf)(__ostream_type &))
Interface for manipulators.
basic_streambuf< _CharT, _Traits > * rdbuf() const
Accessing the underlying buffer.
constexpr std::remove_reference< _Tp >::type && move(_Tp &&__t) noexcept
Convert a value to an rvalue.
bool uncaught_exception() noexcept
void init(basic_streambuf< _CharT, _Traits > *__sb)
All setup is performed here.
basic_ostream< _CharT, _Traits > & flush(basic_ostream< _CharT, _Traits > &__os)
Flushes the output stream.
~sentry()
Possibly flushes the stream.
Performs setup work for output streams.
basic_ostream< _CharT, _Traits > & ends(basic_ostream< _CharT, _Traits > &__os)
Write a null character into the output sequence.
ISO C++ entities toplevel namespace is std.
virtual ~basic_ostream()
Base destructor.