34#ifndef _GLIBCXX_OSTREAM_H
35#define _GLIBCXX_OSTREAM_H 1
38#pragma GCC system_header
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(_S_cast_flt<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(_S_cast_flt<double>(__f));
256#if defined(__STDCPP_FLOAT32_T__) && defined(_GLIBCXX_DOUBLE_IS_IEEE_BINARY64)
257 __attribute__((__always_inline__))
261 return _M_insert(_S_cast_flt<double>(__f));
265#if defined(__STDCPP_FLOAT64_T__) && defined(_GLIBCXX_DOUBLE_IS_IEEE_BINARY64)
266 __attribute__((__always_inline__))
270 return _M_insert(_S_cast_flt<double>(__f));
274#if defined(__STDCPP_FLOAT128_T__) && defined(_GLIBCXX_LDOUBLE_IS_IEEE_BINARY128)
275 __attribute__((__always_inline__))
279 return _M_insert(_S_cast_flt<long double>(__f));
283#if defined(__STDCPP_BFLOAT16_T__) && defined(_GLIBCXX_DOUBLE_IS_IEEE_BINARY64)
284 __attribute__((__always_inline__))
288 return _M_insert(_S_cast_flt<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
447 basic_ostream(
const basic_ostream&) =
delete;
449 basic_ostream(basic_ostream&& __rhs)
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); }
480#pragma GCC diagnostic push
481#pragma GCC diagnostic ignored "-Wc++17-extensions"
482 template<
typename _To,
typename _From>
484 _S_cast_flt(_From __f)
486 _To __d =
static_cast<_To
>(__f);
491#if __cpp_constexpr && __has_builtin(__builtin_bit_cast)
492 if constexpr (
sizeof(__f) ==
sizeof(short))
493 __sign =
static_cast<_To
>(__builtin_bit_cast(
short, __f));
494 else if constexpr (
sizeof(__f) ==
sizeof(int))
495 __sign =
static_cast<_To
>(__builtin_bit_cast(
int, __f));
496 else if constexpr (
sizeof(__f) ==
sizeof(
long long))
497 __sign =
static_cast<_To
>(__builtin_bit_cast(
long long, __f));
500 __sign = __builtin_signbit(__f) ? _To(-1.0) : _To(+1.0);
502 if _GLIBCXX17_CONSTEXPR (__is_same(_To,
double))
503 __d = __builtin_copysign(__d, __sign);
504 else if _GLIBCXX17_CONSTEXPR (__is_same(_To,
long double))
505 __d = __builtin_copysignl(__d, __sign);
509#pragma GCC diagnostic pop
519 template <
typename _CharT,
typename _Traits>
541#pragma GCC diagnostic push
542#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
556 if (_M_os.rdbuf() && _M_os.rdbuf()->pubsync() == -1)
560#pragma GCC diagnostic pop
569#if __cplusplus >= 201103L
572 operator bool()
const
592 template<
typename _CharT,
typename _Traits>
596 if (__out.
width() != 0)
597 return __ostream_insert(__out, &__c, 1);
602 template<
typename _CharT,
typename _Traits>
603 inline basic_ostream<_CharT, _Traits>&
604 operator<<(basic_ostream<_CharT, _Traits>& __out,
char __c)
605 {
return (__out << __out.widen(__c)); }
608 template<
typename _Traits>
612 if (__out.width() != 0)
613 return __ostream_insert(__out, &__c, 1);
619 template<
typename _Traits>
622 {
return (__out <<
static_cast<char>(__c)); }
624 template<
typename _Traits>
627 {
return (__out <<
static_cast<char>(__c)); }
629#if __cplusplus > 201703L
633 template<
typename _Traits>
637#ifdef _GLIBCXX_USE_CHAR8_T
638 template<
typename _Traits>
643 template<
typename _Traits>
647 template<
typename _Traits>
651#ifdef _GLIBCXX_USE_WCHAR_T
652#ifdef _GLIBCXX_USE_CHAR8_T
653 template<
typename _Traits>
658 template<
typename _Traits>
662 template<
typename _Traits>
683 template<
typename _CharT,
typename _Traits>
690 __ostream_insert(__out, __s,
691 static_cast<streamsize>(_Traits::length(__s)));
695 template<
typename _CharT,
typename _Traits>
700 template<
typename _Traits>
707 __ostream_insert(__out, __s,
708 static_cast<streamsize>(_Traits::length(__s)));
713 template<
typename _Traits>
716 {
return (__out <<
reinterpret_cast<const char*
>(__s)); }
718 template<
typename _Traits>
721 {
return (__out <<
reinterpret_cast<const char*
>(__s)); }
723#if __cplusplus > 201703L
727 template<
typename _Traits>
731#ifdef _GLIBCXX_USE_CHAR8_T
732 template<
typename _Traits>
737 template<
typename _Traits>
741 template<
typename _Traits>
745#ifdef _GLIBCXX_USE_WCHAR_T
746#ifdef _GLIBCXX_USE_CHAR8_T
747 template<
typename _Traits>
752 template<
typename _Traits>
756 template<
typename _Traits>
763#if __cplusplus >= 201103L
768#if __cpp_concepts >= 201907L && __glibcxx_type_trait_variable_templates
770 template<
typename _Tp>
771 concept __derived_from_ios_base = is_class_v<_Tp>
772 && (!is_same_v<_Tp, ios_base>)
773 &&
requires (_Tp* __t,
ios_base* __b) { __b = __t; };
775 template<
typename _Os,
typename _Tp>
776 requires __derived_from_ios_base<_Os>
777 &&
requires (_Os& __os,
const _Tp& __t) { __os << __t; }
778 using __rvalue_stream_insertion_t = _Os&&;
780 template<
typename _Tp>
781 using _Require_derived_from_ios_base
782 = _Require<is_class<_Tp>, __not_<is_same<_Tp, ios_base>>,
783 is_convertible<typename add_pointer<_Tp>::type,
ios_base*>>;
785 template<
typename _Os,
typename _Tp,
786 typename = _Require_derived_from_ios_base<_Os>,
789 using __rvalue_stream_insertion_t = _Os&&;
802 template<
typename _Ostream,
typename _Tp>
803 inline __rvalue_stream_insertion_t<_Ostream, _Tp>
811_GLIBCXX_END_NAMESPACE_VERSION
auto declval() noexcept -> decltype(__declval< _Tp >(0))
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.
void setstate(iostate __state)
Sets additional flags in the error state.
void init(basic_streambuf< _CharT, _Traits > *__sb)
All setup is performed here.
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.
The base of the I/O class hierarchy.
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.
~sentry()
Possibly flushes the stream.
sentry(basic_ostream< _CharT, _Traits > &__os)
The constructor performs preparatory work.