33#ifndef _GLIBCXX_OSTREAM
34#define _GLIBCXX_OSTREAM 1
36#pragma GCC system_header
42#if __cplusplus > 202002L
46# define __glibcxx_want_print
49namespace std _GLIBCXX_VISIBILITY(default)
51_GLIBCXX_BEGIN_NAMESPACE_VERSION
65 template<
typename _CharT,
typename _Traits>
70 typedef _CharT char_type;
71 typedef typename _Traits::int_type int_type;
72 typedef typename _Traits::pos_type pos_type;
73 typedef typename _Traits::off_type off_type;
74 typedef _Traits traits_type;
116 operator<<(__ostream_type& (*__pf)(__ostream_type&))
175 {
return _M_insert(__n); }
179 {
return _M_insert(__n); }
183 {
return _M_insert(__n); }
193 return _M_insert(
static_cast<unsigned long>(__n));
204 return _M_insert(
static_cast<unsigned long>(__n));
207#ifdef _GLIBCXX_USE_LONG_LONG
208#pragma GCC diagnostic push
209#pragma GCC diagnostic ignored "-Wlong-long"
212 {
return _M_insert(__n); }
216 {
return _M_insert(__n); }
217#pragma GCC diagnostic pop
232 {
return _M_insert(__f); }
239 return _M_insert(
static_cast<double>(__f));
244 {
return _M_insert(__f); }
247#if defined(__STDCPP_FLOAT16_T__) && defined(_GLIBCXX_DOUBLE_IS_IEEE_BINARY64)
248 __attribute__((__always_inline__))
252 return _M_insert(
static_cast<double>(__f));
256#if defined(__STDCPP_FLOAT32_T__) && defined(_GLIBCXX_DOUBLE_IS_IEEE_BINARY64)
257 __attribute__((__always_inline__))
261 return _M_insert(
static_cast<double>(__f));
265#if defined(__STDCPP_FLOAT64_T__) && defined(_GLIBCXX_DOUBLE_IS_IEEE_BINARY64)
266 __attribute__((__always_inline__))
270 return _M_insert(
static_cast<double>(__f));
274#if defined(__STDCPP_FLOAT128_T__) && defined(_GLIBCXX_LDOUBLE_IS_IEEE_BINARY128)
275 __attribute__((__always_inline__))
279 return _M_insert(
static_cast<long double>(__f));
283#if defined(__STDCPP_BFLOAT16_T__) && defined(_GLIBCXX_DOUBLE_IS_IEEE_BINARY64)
284 __attribute__((__always_inline__))
288 return _M_insert(
static_cast<double>(__f));
302 {
return _M_insert(__p); }
304#if __cplusplus >= 201703L
307 {
return *
this <<
"nullptr"; }
310#if __cplusplus > 202002L
311 __attribute__((__always_inline__))
314 {
return _M_insert(
const_cast<const void*
>(__p)); }
443#if __cplusplus >= 201103L
451 { __ios_type::move(__rhs); }
466 { __ios_type::swap(__rhs); }
469 template<
typename _ValueT>
471 _M_insert(_ValueT __v);
474#if !_GLIBCXX_INLINE_VERSION
476 _M_write(
const char_type* __s,
streamsize __n)
477 { std::__ostream_insert(*
this, __s, __n); }
488 template <
typename _CharT,
typename _Traits>
510#pragma GCC diagnostic push
511#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
525 if (_M_os.rdbuf() && _M_os.rdbuf()->pubsync() == -1)
529#pragma GCC diagnostic pop
538#if __cplusplus >= 201103L
541 operator bool()
const
561 template<
typename _CharT,
typename _Traits>
565 if (__out.
width() != 0)
566 return __ostream_insert(__out, &__c, 1);
571 template<
typename _CharT,
typename _Traits>
572 inline basic_ostream<_CharT, _Traits>&
573 operator<<(basic_ostream<_CharT, _Traits>& __out,
char __c)
574 {
return (__out << __out.widen(__c)); }
577 template<
typename _Traits>
581 if (__out.width() != 0)
582 return __ostream_insert(__out, &__c, 1);
588 template<
typename _Traits>
591 {
return (__out <<
static_cast<char>(__c)); }
593 template<
typename _Traits>
596 {
return (__out <<
static_cast<char>(__c)); }
598#if __cplusplus > 201703L
602 template<
typename _Traits>
606#ifdef _GLIBCXX_USE_CHAR8_T
607 template<
typename _Traits>
612 template<
typename _Traits>
616 template<
typename _Traits>
620#ifdef _GLIBCXX_USE_WCHAR_T
621#ifdef _GLIBCXX_USE_CHAR8_T
622 template<
typename _Traits>
627 template<
typename _Traits>
631 template<
typename _Traits>
652 template<
typename _CharT,
typename _Traits>
659 __ostream_insert(__out, __s,
660 static_cast<streamsize>(_Traits::length(__s)));
664 template<
typename _CharT,
typename _Traits>
669 template<
typename _Traits>
676 __ostream_insert(__out, __s,
677 static_cast<streamsize>(_Traits::length(__s)));
682 template<
typename _Traits>
685 {
return (__out <<
reinterpret_cast<const char*
>(__s)); }
687 template<
typename _Traits>
690 {
return (__out <<
reinterpret_cast<const char*
>(__s)); }
692#if __cplusplus > 201703L
696 template<
typename _Traits>
700#ifdef _GLIBCXX_USE_CHAR8_T
701 template<
typename _Traits>
706 template<
typename _Traits>
710 template<
typename _Traits>
714#ifdef _GLIBCXX_USE_WCHAR_T
715#ifdef _GLIBCXX_USE_CHAR8_T
716 template<
typename _Traits>
721 template<
typename _Traits>
725 template<
typename _Traits>
742 template<
typename _CharT,
typename _Traits>
754 template<
typename _CharT,
typename _Traits>
755 inline basic_ostream<_CharT, _Traits>&
757 {
return __os.
put(_CharT()); }
764 template<
typename _CharT,
typename _Traits>
765 inline basic_ostream<_CharT, _Traits>&
767 {
return __os.
flush(); }
769#if __cplusplus >= 201103L
774#if __cpp_concepts >= 201907L && __glibcxx_type_trait_variable_templates
776 template<
typename _Tp>
777 concept __derived_from_ios_base = is_class_v<_Tp>
778 && (!is_same_v<_Tp, ios_base>)
779 &&
requires (_Tp* __t, ios_base* __b) { __b = __t; };
781 template<
typename _Os,
typename _Tp>
782 requires __derived_from_ios_base<_Os>
783 &&
requires (_Os& __os,
const _Tp& __t) { __os << __t; }
784 using __rvalue_stream_insertion_t = _Os&&;
786 template<
typename _Tp>
787 using _Require_derived_from_ios_base
788 = _Require<is_class<_Tp>, __not_<is_same<_Tp, ios_base>>,
789 is_convertible<typename add_pointer<_Tp>::type,
ios_base*>>;
791 template<
typename _Os,
typename _Tp,
792 typename = _Require_derived_from_ios_base<_Os>,
795 using __rvalue_stream_insertion_t = _Os&&;
808 template<
typename _Ostream,
typename _Tp>
809 inline __rvalue_stream_insertion_t<_Ostream, _Tp>
816#ifdef __glibcxx_syncbuf
817 template<
typename _CharT,
typename _Traits>
825 if (
auto __p =
dynamic_cast<__syncbuf_base*
>(__buf))
826 return &__p->_M_emit_on_sync;
837 bool _M_emit_on_sync =
false;
838 bool _M_needs_sync =
false;
841 template<
typename _CharT,
typename _Traits>
845 if (
bool* __flag = __syncbuf_base<_CharT, _Traits>::_S_get(__os.rdbuf()))
850 template<
typename _CharT,
typename _Traits>
854 if (
bool* __flag = __syncbuf_base<_CharT, _Traits>::_S_get(__os.rdbuf()))
859 template<
typename _CharT,
typename _Traits>
865 ~_Restore() { *_M_flag = _M_prev; }
867 bool _M_prev =
false;
868 bool* _M_flag = &_M_prev;
871 if (
bool* __flag = __syncbuf_base<_CharT, _Traits>::_S_get(__os.rdbuf()))
873 __restore._M_prev = *__flag;
874 __restore._M_flag = __flag;
886 vprint_nonunicode(
ostream& __os, string_view __fmt, format_args __args)
888 ostream::sentry __cerb(__os);
891 __format::_Str_sink<char> __buf;
892 std::vformat_to(__buf.out(), __os.getloc(), __fmt, __args);
893 auto __out = __buf.view();
897 std::__ostream_write(__os, __out.data(), __out.size());
899 __catch(
const __cxxabiv1::__forced_unwind&)
902 __throw_exception_again;
910 vprint_unicode(
ostream& __os, string_view __fmt, format_args __args)
912#if !defined(_WIN32) || defined(__CYGWIN__)
915 std::vprint_nonunicode(__os, __fmt, __args);
917 ostream::sentry __cerb(__os);
920 __format::_Str_sink<char> __buf;
921 std::vformat_to(__buf.out(), __os.getloc(), __fmt, __args);
922 auto __out = __buf.view();
925 error_code __write_to_terminal(
void*, span<char>);
927 if (
auto __term = __open_terminal(__os.rdbuf()))
929#if !defined(_WIN32) || defined(__CYGWIN__)
936 _Guard(
void* __p) : _M_f((FILE*)__p) { }
937 ~_Guard() { std::fclose(_M_f); }
938 _Guard(_Guard&&) =
delete;
939 _Guard& operator=(_Guard&&) =
delete;
948 if (__os.rdbuf()->pubsync() == -1)
950 else if (
auto __e = __write_to_terminal(__term, __out))
954 __catch(
const __cxxabiv1::__forced_unwind&)
957 __throw_exception_again;
963 __os.setstate(__err);
970 std::__ostream_write(__os, __out.data(), __out.size());
972 __catch(
const __cxxabiv1::__forced_unwind&)
975 __throw_exception_again;
983 template<
typename... _Args>
985 print(
ostream& __os, format_string<_Args...> __fmt, _Args&&... __args)
987 auto __fmtargs = std::make_format_args(__args...);
988 if constexpr (__unicode::__literal_encoding_is_utf8())
989 std::vprint_unicode(__os, __fmt.get(), __fmtargs);
991 std::vprint_nonunicode(__os, __fmt.get(), __fmtargs);
994 template<
typename... _Args>
996 println(
ostream& __os, format_string<_Args...> __fmt, _Args&&... __args)
1000 std::print(__os,
"{}\n", std::format(__os.getloc(), __fmt,
1005 inline void println(
ostream& __os)
1007#if defined(_WIN32) && !defined(__CYGWIN__)
1008 if constexpr (__unicode::__literal_encoding_is_utf8())
1009 std::vprint_unicode(__os,
"\n", std::make_format_args());
1019_GLIBCXX_END_NAMESPACE_VERSION
error_code make_error_code(future_errc __errc) noexcept
Overload of make_error_code for future_errc.
basic_streambuf< char > streambuf
Base class for char buffers.
basic_ostream< char > ostream
Base class for char output streams.
auto declval() noexcept -> decltype(__declval< _Tp >(0))
constexpr std::remove_reference< _Tp >::type && move(_Tp &&__t) noexcept
Convert a value to an rvalue.
constexpr _Tp && forward(typename std::remove_reference< _Tp >::type &__t) noexcept
Forward an lvalue.
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.
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_ios(basic_streambuf< _CharT, _Traits > *__sb)
Constructor performs initialization.
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 & seekp(off_type, ios_base::seekdir)
Changing 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.
Template class basic_iostream.
~sentry()
Possibly flushes the stream.
sentry(basic_ostream< _CharT, _Traits > &__os)
The constructor performs preparatory work.
The base of the I/O class hierarchy.
_Ios_Iostate iostate
This is a bitmask type.
static const iostate goodbit
Indicates all is well.
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.