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>
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;
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)); }
387 #if __cplusplus >= 201103L
395 { __ios_type::move(__rhs); }
402 operator=(basic_ostream&& __rhs)
409 swap(basic_ostream& __rhs)
410 { __ios_type::swap(__rhs); }
413 template<
typename _ValueT>
415 _M_insert(_ValueT __v);
418 #if !_GLIBCXX_INLINE_VERSION
420 _M_write(
const char_type* __s,
streamsize __n)
421 { std::__ostream_insert(*
this, __s, __n); }
432 template <
typename _CharT,
typename _Traits>
454 #pragma GCC diagnostic push
455 #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
469 if (_M_os.
rdbuf() && _M_os.
rdbuf()->pubsync() == -1)
473 #pragma GCC diagnostic pop
482 #if __cplusplus >= 201103L
485 operator bool()
const
505 template<
typename _CharT,
typename _Traits>
509 if (__out.
width() != 0)
510 return __ostream_insert(__out, &__c, 1);
515 template<
typename _CharT,
typename _Traits>
516 inline basic_ostream<_CharT, _Traits>&
517 operator<<(basic_ostream<_CharT, _Traits>& __out,
char __c)
518 {
return (__out << __out.widen(__c)); }
521 template<
typename _Traits>
522 inline basic_ostream<char, _Traits>&
523 operator<<(basic_ostream<char, _Traits>& __out,
char __c)
525 if (__out.width() != 0)
526 return __ostream_insert(__out, &__c, 1);
532 template<
typename _Traits>
533 inline basic_ostream<char, _Traits>&
534 operator<<(basic_ostream<char, _Traits>& __out,
signed char __c)
535 {
return (__out <<
static_cast<char>(__c)); }
537 template<
typename _Traits>
538 inline basic_ostream<char, _Traits>&
539 operator<<(basic_ostream<char, _Traits>& __out,
unsigned char __c)
540 {
return (__out <<
static_cast<char>(__c)); }
542 #if __cplusplus > 201703L
546 template<
typename _Traits>
547 basic_ostream<char, _Traits>&
548 operator<<(basic_ostream<char, _Traits>&,
wchar_t) =
delete;
550 #ifdef _GLIBCXX_USE_CHAR8_T
551 template<
typename _Traits>
552 basic_ostream<char, _Traits>&
553 operator<<(basic_ostream<char, _Traits>&, char8_t) =
delete;
556 template<
typename _Traits>
557 basic_ostream<char, _Traits>&
558 operator<<(basic_ostream<char, _Traits>&, char16_t) =
delete;
560 template<
typename _Traits>
561 basic_ostream<char, _Traits>&
562 operator<<(basic_ostream<char, _Traits>&, char32_t) =
delete;
564 #ifdef _GLIBCXX_USE_WCHAR_T
565 #ifdef _GLIBCXX_USE_CHAR8_T
566 template<
typename _Traits>
567 basic_ostream<wchar_t, _Traits>&
568 operator<<(basic_ostream<wchar_t, _Traits>&, char8_t) =
delete;
571 template<
typename _Traits>
572 basic_ostream<wchar_t, _Traits>&
573 operator<<(basic_ostream<wchar_t, _Traits>&, char16_t) =
delete;
575 template<
typename _Traits>
576 basic_ostream<wchar_t, _Traits>&
577 operator<<(basic_ostream<wchar_t, _Traits>&, char32_t) =
delete;
596 template<
typename _CharT,
typename _Traits>
597 inline basic_ostream<_CharT, _Traits>&
598 operator<<(basic_ostream<_CharT, _Traits>& __out,
const _CharT* __s)
603 __ostream_insert(__out, __s,
604 static_cast<streamsize>(_Traits::length(__s)));
608 template<
typename _CharT,
typename _Traits>
609 basic_ostream<_CharT, _Traits> &
610 operator<<(basic_ostream<_CharT, _Traits>& __out,
const char* __s);
613 template<
typename _Traits>
614 inline basic_ostream<char, _Traits>&
615 operator<<(basic_ostream<char, _Traits>& __out,
const char* __s)
620 __ostream_insert(__out, __s,
621 static_cast<streamsize>(_Traits::length(__s)));
626 template<
typename _Traits>
627 inline basic_ostream<char, _Traits>&
628 operator<<(basic_ostream<char, _Traits>& __out,
const signed char* __s)
629 {
return (__out <<
reinterpret_cast<const char*
>(__s)); }
631 template<
typename _Traits>
632 inline basic_ostream<char, _Traits> &
633 operator<<(basic_ostream<char, _Traits>& __out,
const unsigned char* __s)
634 {
return (__out <<
reinterpret_cast<const char*
>(__s)); }
636 #if __cplusplus > 201703L
640 template<
typename _Traits>
641 basic_ostream<char, _Traits>&
642 operator<<(basic_ostream<char, _Traits>&,
const wchar_t*) =
delete;
644 #ifdef _GLIBCXX_USE_CHAR8_T
645 template<
typename _Traits>
646 basic_ostream<char, _Traits>&
647 operator<<(basic_ostream<char, _Traits>&,
const char8_t*) =
delete;
650 template<
typename _Traits>
651 basic_ostream<char, _Traits>&
652 operator<<(basic_ostream<char, _Traits>&,
const char16_t*) =
delete;
654 template<
typename _Traits>
655 basic_ostream<char, _Traits>&
656 operator<<(basic_ostream<char, _Traits>&,
const char32_t*) =
delete;
658 #ifdef _GLIBCXX_USE_WCHAR_T
659 #ifdef _GLIBCXX_USE_CHAR8_T
660 template<
typename _Traits>
661 basic_ostream<wchar_t, _Traits>&
662 operator<<(basic_ostream<wchar_t, _Traits>&,
const char8_t*) =
delete;
665 template<
typename _Traits>
666 basic_ostream<wchar_t, _Traits>&
667 operator<<(basic_ostream<wchar_t, _Traits>&,
const char16_t*) =
delete;
669 template<
typename _Traits>
670 basic_ostream<wchar_t, _Traits>&
671 operator<<(basic_ostream<wchar_t, _Traits>&,
const char32_t*) =
delete;
686 template<
typename _CharT,
typename _Traits>
687 inline basic_ostream<_CharT, _Traits>&
689 {
return flush(__os.put(__os.widen(
'\n'))); }
698 template<
typename _CharT,
typename _Traits>
699 inline basic_ostream<_CharT, _Traits>&
701 {
return __os.put(_CharT()); }
708 template<
typename _CharT,
typename _Traits>
709 inline basic_ostream<_CharT, _Traits>&
711 {
return __os.flush(); }
713 #if __cplusplus >= 201103L
718 #if __cpp_lib_concepts
720 template<
typename _Tp>
721 concept __derived_from_ios_base = is_class_v<_Tp>
722 && (!is_same_v<_Tp, ios_base>)
723 && requires (_Tp* __t, ios_base* __b) { __b = __t; };
725 template<
typename _Os,
typename _Tp>
726 requires __derived_from_ios_base<_Os>
727 && requires (_Os& __os,
const _Tp& __t) { __os << __t; }
728 using __rvalue_stream_insertion_t = _Os&&;
730 template<
typename _Tp>
731 using _Require_derived_from_ios_base
732 = _Require<is_class<_Tp>, __not_<is_same<_Tp, ios_base>>,
733 is_convertible<typename add_pointer<_Tp>::type, ios_base*>>;
735 template<
typename _Os,
typename _Tp,
736 typename = _Require_derived_from_ios_base<_Os>,
738 = decltype(std::declval<_Os&>() << std::declval<const _Tp&>())>
739 using __rvalue_stream_insertion_t = _Os&&;
752 template<
typename _Ostream,
typename _Tp>
753 inline __rvalue_stream_insertion_t<_Ostream, _Tp>
760 #if __cplusplus > 201703L && _GLIBCXX_USE_CXX11_ABI
761 template<
typename _CharT,
typename _Traits>
762 class __syncbuf_base :
public basic_streambuf<_CharT, _Traits>
766 _S_get(basic_streambuf<_CharT, _Traits>* __buf [[maybe_unused]]) noexcept
769 if (
auto __p =
dynamic_cast<__syncbuf_base*
>(__buf))
770 return &__p->_M_emit_on_sync;
776 __syncbuf_base(basic_streambuf<_CharT, _Traits>* __w =
nullptr)
780 basic_streambuf<_CharT, _Traits>* _M_wrapped =
nullptr;
781 bool _M_emit_on_sync =
false;
782 bool _M_needs_sync =
false;
785 template<
typename _CharT,
typename _Traits>
786 inline basic_ostream<_CharT, _Traits>&
787 emit_on_flush(basic_ostream<_CharT, _Traits>& __os)
789 if (
bool* __flag = __syncbuf_base<_CharT, _Traits>::_S_get(__os.rdbuf()))
794 template<
typename _CharT,
typename _Traits>
795 inline basic_ostream<_CharT, _Traits>&
796 noemit_on_flush(basic_ostream<_CharT, _Traits>& __os)
798 if (
bool* __flag = __syncbuf_base<_CharT, _Traits>::_S_get(__os.rdbuf()))
803 template<
typename _CharT,
typename _Traits>
804 inline basic_ostream<_CharT, _Traits>&
805 flush_emit(basic_ostream<_CharT, _Traits>& __os)
809 ~_Restore() { *_M_flag = _M_prev; }
811 bool _M_prev =
false;
812 bool* _M_flag = &_M_prev;
815 if (
bool* __flag = __syncbuf_base<_CharT, _Traits>::_S_get(__os.rdbuf()))
817 __restore._M_prev = *__flag;
818 __restore._M_flag = __flag;
830 _GLIBCXX_END_NAMESPACE_VERSION
constexpr std::remove_reference< _Tp >::type && move(_Tp &&__t) noexcept
Convert a value to an rvalue.
bool uncaught_exception() noexcept
ISO C++ entities toplevel namespace is std.
ptrdiff_t streamsize
Integral type for I/O operation counts and buffer sizes.
std::basic_ostream< _CharT, _Traits > & operator<<(std::basic_ostream< _CharT, _Traits > &__os, const bitset< _Nb > &__x)
Global I/O operators for bitsets.
basic_ostream< _CharT, _Traits > & endl(basic_ostream< _CharT, _Traits > &__os)
Write a newline and flush the stream.
basic_ostream< _CharT, _Traits > & flush(basic_ostream< _CharT, _Traits > &__os)
Flushes the output stream.
basic_ostream< _CharT, _Traits > & ends(basic_ostream< _CharT, _Traits > &__os)
Write a null character into the output sequence.
Template class basic_ios, virtual base class for all stream classes.
basic_streambuf< _CharT, _Traits > * rdbuf() const
Accessing the underlying buffer.
void setstate(iostate __state)
Sets additional flags in the error state.
void init(basic_streambuf< _CharT, _Traits > *__sb)
All setup is performed here.
The actual work of input and output (interface).
Template class basic_ostream.
__ostream_type & write(const char_type *__s, streamsize __n)
Character string insertion.
__ostream_type & operator<<(__ostream_type &(*__pf)(__ostream_type &))
Interface for manipulators.
pos_type tellp()
Getting the current write position.
__ostream_type & put(char_type __c)
Simple insertion.
basic_ostream(__streambuf_type *__sb)
Base constructor.
__ostream_type & flush()
Synchronizing the stream buffer.
__ostream_type & seekp(pos_type)
Changing the current write position.
virtual ~basic_ostream()
Base destructor.
Performs setup work for output streams.
~sentry()
Possibly flushes the stream.
The base of the I/O class hierarchy.
fmtflags flags() const
Access to format flags.
static const fmtflags unitbuf
Flushes output after each output operation.
static const iostate badbit
Indicates a loss of integrity in an input or output sequence (such as an irrecoverable read error fro...
streamsize width() const
Flags access.
_Ios_Seekdir seekdir
This is an enumerated type.
Primary class template ctype facet.
Primary class template num_put.