33#ifndef _GLIBCXX_OSTREAM
34#define _GLIBCXX_OSTREAM 1
36#pragma GCC system_header
43namespace std _GLIBCXX_VISIBILITY(default)
45_GLIBCXX_BEGIN_NAMESPACE_VERSION
59 template<
typename _CharT,
typename _Traits>
64 typedef _CharT char_type;
65 typedef typename _Traits::int_type int_type;
66 typedef typename _Traits::pos_type pos_type;
67 typedef typename _Traits::off_type off_type;
68 typedef _Traits traits_type;
169 {
return _M_insert(__n); }
173 {
return _M_insert(__n); }
177 {
return _M_insert(__n); }
187 return _M_insert(
static_cast<unsigned long>(__n));
198 return _M_insert(
static_cast<unsigned long>(__n));
201#ifdef _GLIBCXX_USE_LONG_LONG
204 {
return _M_insert(__n); }
208 {
return _M_insert(__n); }
223 {
return _M_insert(__f); }
230 return _M_insert(
static_cast<double>(__f));
235 {
return _M_insert(__f); }
238#if defined(__STDCPP_FLOAT16_T__) && defined(_GLIBCXX_DOUBLE_IS_IEEE_BINARY64)
239 __attribute__((__always_inline__))
243 return _M_insert(
static_cast<double>(__f));
247#if defined(__STDCPP_FLOAT32_T__) && defined(_GLIBCXX_DOUBLE_IS_IEEE_BINARY64)
248 __attribute__((__always_inline__))
252 return _M_insert(
static_cast<double>(__f));
256#if defined(__STDCPP_FLOAT64_T__) && defined(_GLIBCXX_DOUBLE_IS_IEEE_BINARY64)
257 __attribute__((__always_inline__))
261 return _M_insert(
static_cast<double>(__f));
265#if defined(__STDCPP_FLOAT128_T__) && defined(_GLIBCXX_LDOUBLE_IS_IEEE_BINARY128)
266 __attribute__((__always_inline__))
270 return _M_insert(
static_cast<long double>(__f));
274#if defined(__STDCPP_BFLOAT16_T__) && defined(_GLIBCXX_DOUBLE_IS_IEEE_BINARY64)
275 __attribute__((__always_inline__))
279 return _M_insert(
static_cast<double>(__f));
293 {
return _M_insert(__p); }
295#if __cplusplus >= 201703L
298 {
return *
this <<
"nullptr"; }
301#if __cplusplus > 202002L
302 __attribute__((__always_inline__))
305 {
return _M_insert(
const_cast<const void*
>(__p)); }
434#if __cplusplus >= 201103L
442 { __ios_type::move(__rhs); }
449 operator=(basic_ostream&& __rhs)
456 swap(basic_ostream& __rhs)
460 template<
typename _ValueT>
462 _M_insert(_ValueT __v);
465#if !_GLIBCXX_INLINE_VERSION
467 _M_write(
const char_type* __s,
streamsize __n)
468 { std::__ostream_insert(*
this, __s, __n); }
479 template <
typename _CharT,
typename _Traits>
501#pragma GCC diagnostic push
502#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
516 if (_M_os.
rdbuf() && _M_os.
rdbuf()->pubsync() == -1)
520#pragma GCC diagnostic pop
529#if __cplusplus >= 201103L
532 operator bool()
const
552 template<
typename _CharT,
typename _Traits>
556 if (__out.
width() != 0)
557 return __ostream_insert(__out, &__c, 1);
562 template<
typename _CharT,
typename _Traits>
563 inline basic_ostream<_CharT, _Traits>&
564 operator<<(basic_ostream<_CharT, _Traits>& __out,
char __c)
565 {
return (__out << __out.widen(__c)); }
568 template<
typename _Traits>
569 inline basic_ostream<char, _Traits>&
570 operator<<(basic_ostream<char, _Traits>& __out,
char __c)
572 if (__out.width() != 0)
573 return __ostream_insert(__out, &__c, 1);
579 template<
typename _Traits>
580 inline basic_ostream<char, _Traits>&
581 operator<<(basic_ostream<char, _Traits>& __out,
signed char __c)
582 {
return (__out <<
static_cast<char>(__c)); }
584 template<
typename _Traits>
585 inline basic_ostream<char, _Traits>&
586 operator<<(basic_ostream<char, _Traits>& __out,
unsigned char __c)
587 {
return (__out <<
static_cast<char>(__c)); }
589#if __cplusplus > 201703L
593 template<
typename _Traits>
594 basic_ostream<char, _Traits>&
595 operator<<(basic_ostream<char, _Traits>&,
wchar_t) =
delete;
597#ifdef _GLIBCXX_USE_CHAR8_T
598 template<
typename _Traits>
599 basic_ostream<char, _Traits>&
600 operator<<(basic_ostream<char, _Traits>&,
char8_t) =
delete;
603 template<
typename _Traits>
604 basic_ostream<char, _Traits>&
605 operator<<(basic_ostream<char, _Traits>&,
char16_t) =
delete;
607 template<
typename _Traits>
608 basic_ostream<char, _Traits>&
609 operator<<(basic_ostream<char, _Traits>&,
char32_t) =
delete;
611#ifdef _GLIBCXX_USE_WCHAR_T
612#ifdef _GLIBCXX_USE_CHAR8_T
613 template<
typename _Traits>
614 basic_ostream<wchar_t, _Traits>&
615 operator<<(basic_ostream<wchar_t, _Traits>&,
char8_t) =
delete;
618 template<
typename _Traits>
619 basic_ostream<wchar_t, _Traits>&
620 operator<<(basic_ostream<wchar_t, _Traits>&,
char16_t) =
delete;
622 template<
typename _Traits>
623 basic_ostream<wchar_t, _Traits>&
624 operator<<(basic_ostream<wchar_t, _Traits>&,
char32_t) =
delete;
643 template<
typename _CharT,
typename _Traits>
644 inline basic_ostream<_CharT, _Traits>&
645 operator<<(basic_ostream<_CharT, _Traits>& __out,
const _CharT* __s)
650 __ostream_insert(__out, __s,
651 static_cast<streamsize>(_Traits::length(__s)));
655 template<
typename _CharT,
typename _Traits>
656 basic_ostream<_CharT, _Traits> &
657 operator<<(basic_ostream<_CharT, _Traits>& __out,
const char* __s);
660 template<
typename _Traits>
661 inline basic_ostream<char, _Traits>&
662 operator<<(basic_ostream<char, _Traits>& __out,
const char* __s)
667 __ostream_insert(__out, __s,
668 static_cast<streamsize>(_Traits::length(__s)));
673 template<
typename _Traits>
674 inline basic_ostream<char, _Traits>&
675 operator<<(basic_ostream<char, _Traits>& __out,
const signed char* __s)
676 {
return (__out <<
reinterpret_cast<const char*
>(__s)); }
678 template<
typename _Traits>
679 inline basic_ostream<char, _Traits> &
680 operator<<(basic_ostream<char, _Traits>& __out,
const unsigned char* __s)
681 {
return (__out <<
reinterpret_cast<const char*
>(__s)); }
683#if __cplusplus > 201703L
687 template<
typename _Traits>
688 basic_ostream<char, _Traits>&
689 operator<<(basic_ostream<char, _Traits>&,
const wchar_t*) =
delete;
691#ifdef _GLIBCXX_USE_CHAR8_T
692 template<
typename _Traits>
693 basic_ostream<char, _Traits>&
694 operator<<(basic_ostream<char, _Traits>&,
const char8_t*) =
delete;
697 template<
typename _Traits>
698 basic_ostream<char, _Traits>&
699 operator<<(basic_ostream<char, _Traits>&,
const char16_t*) =
delete;
701 template<
typename _Traits>
702 basic_ostream<char, _Traits>&
703 operator<<(basic_ostream<char, _Traits>&,
const char32_t*) =
delete;
705#ifdef _GLIBCXX_USE_WCHAR_T
706#ifdef _GLIBCXX_USE_CHAR8_T
707 template<
typename _Traits>
708 basic_ostream<wchar_t, _Traits>&
709 operator<<(basic_ostream<wchar_t, _Traits>&,
const char8_t*) =
delete;
712 template<
typename _Traits>
713 basic_ostream<wchar_t, _Traits>&
714 operator<<(basic_ostream<wchar_t, _Traits>&,
const char16_t*) =
delete;
716 template<
typename _Traits>
717 basic_ostream<wchar_t, _Traits>&
718 operator<<(basic_ostream<wchar_t, _Traits>&,
const char32_t*) =
delete;
733 template<
typename _CharT,
typename _Traits>
734 inline basic_ostream<_CharT, _Traits>&
745 template<
typename _CharT,
typename _Traits>
746 inline basic_ostream<_CharT, _Traits>&
748 {
return __os.
put(_CharT()); }
755 template<
typename _CharT,
typename _Traits>
756 inline basic_ostream<_CharT, _Traits>&
758 {
return __os.
flush(); }
760#if __cplusplus >= 201103L
765#if __cpp_lib_concepts
767 template<
typename _Tp>
768 concept __derived_from_ios_base = is_class_v<_Tp>
769 && (!is_same_v<_Tp, ios_base>)
770 &&
requires (_Tp* __t, ios_base* __b) { __b = __t; };
772 template<
typename _Os,
typename _Tp>
773 requires __derived_from_ios_base<_Os>
774 &&
requires (_Os& __os,
const _Tp& __t) { __os << __t; }
775 using __rvalue_stream_insertion_t = _Os&&;
777 template<
typename _Tp>
778 using _Require_derived_from_ios_base
779 = _Require<is_class<_Tp>, __not_<is_same<_Tp, ios_base>>,
780 is_convertible<typename add_pointer<_Tp>::type, ios_base*>>;
782 template<
typename _Os,
typename _Tp,
783 typename = _Require_derived_from_ios_base<_Os>,
785 =
decltype(std::declval<_Os&>() << std::declval<const _Tp&>())>
786 using __rvalue_stream_insertion_t = _Os&&;
799 template<
typename _Ostream,
typename _Tp>
800 inline __rvalue_stream_insertion_t<_Ostream, _Tp>
807#if __cplusplus > 201703L && _GLIBCXX_USE_CXX11_ABI
808 template<
typename _CharT,
typename _Traits>
809 class __syncbuf_base :
public basic_streambuf<_CharT, _Traits>
813 _S_get(basic_streambuf<_CharT, _Traits>* __buf [[maybe_unused]])
noexcept
816 if (
auto __p =
dynamic_cast<__syncbuf_base*
>(__buf))
817 return &__p->_M_emit_on_sync;
823 __syncbuf_base(basic_streambuf<_CharT, _Traits>* __w =
nullptr)
827 basic_streambuf<_CharT, _Traits>* _M_wrapped =
nullptr;
828 bool _M_emit_on_sync =
false;
829 bool _M_needs_sync =
false;
832 template<
typename _CharT,
typename _Traits>
833 inline basic_ostream<_CharT, _Traits>&
834 emit_on_flush(basic_ostream<_CharT, _Traits>& __os)
836 if (
bool* __flag = __syncbuf_base<_CharT, _Traits>::_S_get(__os.rdbuf()))
841 template<
typename _CharT,
typename _Traits>
842 inline basic_ostream<_CharT, _Traits>&
843 noemit_on_flush(basic_ostream<_CharT, _Traits>& __os)
845 if (
bool* __flag = __syncbuf_base<_CharT, _Traits>::_S_get(__os.rdbuf()))
850 template<
typename _CharT,
typename _Traits>
851 inline basic_ostream<_CharT, _Traits>&
852 flush_emit(basic_ostream<_CharT, _Traits>& __os)
856 ~_Restore() { *_M_flag = _M_prev; }
858 bool _M_prev =
false;
859 bool* _M_flag = &_M_prev;
862 if (
bool* __flag = __syncbuf_base<_CharT, _Traits>::_S_get(__os.rdbuf()))
864 __restore._M_prev = *__flag;
865 __restore._M_flag = __flag;
877_GLIBCXX_END_NAMESPACE_VERSION
constexpr std::remove_reference< _Tp >::type && move(_Tp &&__t) noexcept
Convert a value to an rvalue.
void swap(any &__x, any &__y) noexcept
Exchange the states of two any objects.
bool uncaught_exception() noexcept
ISO C++ entities toplevel namespace is std.
ptrdiff_t streamsize
Integral type for I/O operation counts and buffer sizes.
basic_ostream< _CharT, _Traits > & ends(basic_ostream< _CharT, _Traits > &__os)
Write a null character into the output sequence.
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.
std::basic_ostream< _CharT, _Traits > & operator<<(std::basic_ostream< _CharT, _Traits > &__os, const bitset< _Nb > &__x)
Global I/O operators for bitsets.
Template class basic_ios, virtual base class for all stream classes.
void setstate(iostate __state)
Sets additional flags in the error state.
void init(basic_streambuf< _CharT, _Traits > *__sb)
All setup is performed here.
char_type widen(char __c) const
Widens characters.
basic_streambuf< _CharT, _Traits > * rdbuf() const
Accessing the underlying buffer.
The actual work of input and output (interface).
Template class basic_ostream.
__ostream_type & write(const char_type *__s, streamsize __n)
Character string insertion.
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.
__ostream_type & operator<<(__ostream_type &(*__pf)(__ostream_type &))
Interface for manipulators.
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.