File indexing completed on 2026-05-03 08:13:58
0001
0002
0003
0004
0005
0006
0007
0008
0009 #ifndef _LIBCPP___OSTREAM_BASIC_OSTREAM_H
0010 #define _LIBCPP___OSTREAM_BASIC_OSTREAM_H
0011
0012 #include <__config>
0013
0014 #if _LIBCPP_HAS_LOCALIZATION
0015
0016 # include <__exception/operations.h>
0017 # include <__fwd/memory.h>
0018 # include <__memory/unique_ptr.h>
0019 # include <__new/exceptions.h>
0020 # include <__ostream/put_character_sequence.h>
0021 # include <__system_error/error_code.h>
0022 # include <__type_traits/conjunction.h>
0023 # include <__type_traits/enable_if.h>
0024 # include <__type_traits/is_base_of.h>
0025 # include <__type_traits/void_t.h>
0026 # include <__utility/declval.h>
0027 # include <bitset>
0028 # include <ios>
0029 # include <locale>
0030 # include <streambuf>
0031 # include <string_view>
0032
0033 # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
0034 # pragma GCC system_header
0035 # endif
0036
0037 _LIBCPP_PUSH_MACROS
0038 # include <__undef_macros>
0039
0040 _LIBCPP_BEGIN_NAMESPACE_STD
0041
0042 template <class _CharT, class _Traits>
0043 class _LIBCPP_TEMPLATE_VIS basic_ostream : virtual public basic_ios<_CharT, _Traits> {
0044 public:
0045
0046 typedef _CharT char_type;
0047 typedef _Traits traits_type;
0048 typedef typename traits_type::int_type int_type;
0049 typedef typename traits_type::pos_type pos_type;
0050 typedef typename traits_type::off_type off_type;
0051
0052
0053 inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1 explicit basic_ostream(basic_streambuf<char_type, traits_type>* __sb) {
0054 this->init(__sb);
0055 }
0056 ~basic_ostream() override;
0057
0058 basic_ostream(const basic_ostream& __rhs) = delete;
0059 basic_ostream& operator=(const basic_ostream& __rhs) = delete;
0060
0061 protected:
0062 inline _LIBCPP_HIDE_FROM_ABI basic_ostream(basic_ostream&& __rhs);
0063
0064
0065 inline _LIBCPP_HIDE_FROM_ABI basic_ostream& operator=(basic_ostream&& __rhs);
0066
0067 inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1 void swap(basic_ostream& __rhs) {
0068 basic_ios<char_type, traits_type>::swap(__rhs);
0069 }
0070
0071 public:
0072
0073 class _LIBCPP_TEMPLATE_VIS sentry;
0074
0075
0076 inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1 basic_ostream& operator<<(basic_ostream& (*__pf)(basic_ostream&)) {
0077 return __pf(*this);
0078 }
0079
0080 inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1 basic_ostream&
0081 operator<<(basic_ios<char_type, traits_type>& (*__pf)(basic_ios<char_type, traits_type>&)) {
0082 __pf(*this);
0083 return *this;
0084 }
0085
0086 inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1 basic_ostream& operator<<(ios_base& (*__pf)(ios_base&)) {
0087 __pf(*this);
0088 return *this;
0089 }
0090
0091 template <class _Tp>
0092 _LIBCPP_HIDE_FROM_ABI basic_ostream& __put_num(_Tp __value) {
0093 # if _LIBCPP_HAS_EXCEPTIONS
0094 try {
0095 # endif
0096 sentry __s(*this);
0097 if (__s) {
0098 using _Fp = num_put<char_type, ostreambuf_iterator<char_type, traits_type> >;
0099 const _Fp& __facet = std::use_facet<_Fp>(this->getloc());
0100 if (__facet.put(*this, *this, this->fill(), __value).failed())
0101 this->setstate(ios_base::badbit | ios_base::failbit);
0102 }
0103 # if _LIBCPP_HAS_EXCEPTIONS
0104 } catch (...) {
0105 this->__set_badbit_and_consider_rethrow();
0106 }
0107 # endif
0108 return *this;
0109 }
0110
0111 template <class _Tp>
0112 _LIBCPP_HIDE_FROM_ABI basic_ostream& __put_num_integer_promote(_Tp __value) {
0113 # if _LIBCPP_HAS_EXCEPTIONS
0114 try {
0115 # endif
0116 sentry __s(*this);
0117 if (__s) {
0118 ios_base::fmtflags __flags = ios_base::flags() & ios_base::basefield;
0119
0120 using _Fp = num_put<char_type, ostreambuf_iterator<char_type, traits_type> >;
0121 const _Fp& __facet = std::use_facet<_Fp>(this->getloc());
0122 if (__facet
0123 .put(*this,
0124 *this,
0125 this->fill(),
0126 __flags == ios_base::oct || __flags == ios_base::hex
0127 ? static_cast<__copy_unsigned_t<_Tp, long> >(std::__to_unsigned_like(__value))
0128 : static_cast<__copy_unsigned_t<_Tp, long> >(__value))
0129 .failed())
0130 this->setstate(ios_base::badbit | ios_base::failbit);
0131 }
0132 # if _LIBCPP_HAS_EXCEPTIONS
0133 } catch (...) {
0134 this->__set_badbit_and_consider_rethrow();
0135 }
0136 # endif
0137 return *this;
0138 }
0139
0140 basic_ostream& operator<<(bool __n);
0141 basic_ostream& operator<<(short __n);
0142 basic_ostream& operator<<(unsigned short __n);
0143 basic_ostream& operator<<(int __n);
0144 basic_ostream& operator<<(unsigned int __n);
0145 basic_ostream& operator<<(long __n);
0146 basic_ostream& operator<<(unsigned long __n);
0147 basic_ostream& operator<<(long long __n);
0148 basic_ostream& operator<<(unsigned long long __n);
0149 basic_ostream& operator<<(float __f);
0150 basic_ostream& operator<<(double __f);
0151 basic_ostream& operator<<(long double __f);
0152 basic_ostream& operator<<(const void* __p);
0153
0154 # if _LIBCPP_STD_VER >= 23
0155 _LIBCPP_HIDE_FROM_ABI basic_ostream& operator<<(const volatile void* __p) {
0156 return operator<<(const_cast<const void*>(__p));
0157 }
0158 # endif
0159
0160 basic_ostream& operator<<(basic_streambuf<char_type, traits_type>* __sb);
0161
0162 # if _LIBCPP_STD_VER >= 17
0163
0164
0165 _LIBCPP_HIDE_FROM_ABI basic_ostream& operator<<(nullptr_t) { return *this << "nullptr"; }
0166 # endif
0167
0168
0169 basic_ostream& put(char_type __c);
0170 basic_ostream& write(const char_type* __s, streamsize __n);
0171 basic_ostream& flush();
0172
0173
0174 inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1 pos_type tellp();
0175 inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1 basic_ostream& seekp(pos_type __pos);
0176 inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1 basic_ostream& seekp(off_type __off, ios_base::seekdir __dir);
0177
0178 protected:
0179 _LIBCPP_HIDE_FROM_ABI basic_ostream() {}
0180 };
0181
0182 template <class _CharT, class _Traits>
0183 class _LIBCPP_TEMPLATE_VIS basic_ostream<_CharT, _Traits>::sentry {
0184 bool __ok_;
0185 basic_ostream<_CharT, _Traits>& __os_;
0186
0187 public:
0188 explicit sentry(basic_ostream<_CharT, _Traits>& __os);
0189 ~sentry();
0190 sentry(const sentry&) = delete;
0191 sentry& operator=(const sentry&) = delete;
0192
0193 _LIBCPP_HIDE_FROM_ABI explicit operator bool() const { return __ok_; }
0194 };
0195
0196 template <class _CharT, class _Traits>
0197 basic_ostream<_CharT, _Traits>::sentry::sentry(basic_ostream<_CharT, _Traits>& __os) : __ok_(false), __os_(__os) {
0198 if (__os.good()) {
0199 if (__os.tie())
0200 __os.tie()->flush();
0201 __ok_ = true;
0202 }
0203 }
0204
0205 template <class _CharT, class _Traits>
0206 basic_ostream<_CharT, _Traits>::sentry::~sentry() {
0207 if (__os_.rdbuf() && __os_.good() && (__os_.flags() & ios_base::unitbuf) && uncaught_exceptions() == 0) {
0208 # if _LIBCPP_HAS_EXCEPTIONS
0209 try {
0210 # endif
0211 if (__os_.rdbuf()->pubsync() == -1)
0212 __os_.setstate(ios_base::badbit);
0213 # if _LIBCPP_HAS_EXCEPTIONS
0214 } catch (...) {
0215 }
0216 # endif
0217 }
0218 }
0219
0220 template <class _CharT, class _Traits>
0221 basic_ostream<_CharT, _Traits>::basic_ostream(basic_ostream&& __rhs) {
0222 this->move(__rhs);
0223 }
0224
0225 template <class _CharT, class _Traits>
0226 basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::operator=(basic_ostream&& __rhs) {
0227 swap(__rhs);
0228 return *this;
0229 }
0230
0231 template <class _CharT, class _Traits>
0232 basic_ostream<_CharT, _Traits>::~basic_ostream() {}
0233
0234 template <class _CharT, class _Traits>
0235 basic_ostream<_CharT, _Traits>&
0236 basic_ostream<_CharT, _Traits>::operator<<(basic_streambuf<char_type, traits_type>* __sb) {
0237 # if _LIBCPP_HAS_EXCEPTIONS
0238 try {
0239 # endif
0240 sentry __s(*this);
0241 if (__s) {
0242 if (__sb) {
0243 # if _LIBCPP_HAS_EXCEPTIONS
0244 try {
0245 # endif
0246 typedef istreambuf_iterator<_CharT, _Traits> _Ip;
0247 typedef ostreambuf_iterator<_CharT, _Traits> _Op;
0248 _Ip __i(__sb);
0249 _Ip __eof;
0250 _Op __o(*this);
0251 size_t __c = 0;
0252 for (; __i != __eof; ++__i, ++__o, ++__c) {
0253 *__o = *__i;
0254 if (__o.failed())
0255 break;
0256 }
0257 if (__c == 0)
0258 this->setstate(ios_base::failbit);
0259 # if _LIBCPP_HAS_EXCEPTIONS
0260 } catch (...) {
0261 this->__set_failbit_and_consider_rethrow();
0262 }
0263 # endif
0264 } else
0265 this->setstate(ios_base::badbit);
0266 }
0267 # if _LIBCPP_HAS_EXCEPTIONS
0268 } catch (...) {
0269 this->__set_badbit_and_consider_rethrow();
0270 }
0271 # endif
0272 return *this;
0273 }
0274
0275 template <class _CharT, class _Traits>
0276 basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::operator<<(bool __n) {
0277 return __put_num(__n);
0278 }
0279
0280 template <class _CharT, class _Traits>
0281 basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::operator<<(short __n) {
0282 return __put_num_integer_promote(__n);
0283 }
0284
0285 template <class _CharT, class _Traits>
0286 basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::operator<<(unsigned short __n) {
0287 return __put_num_integer_promote(__n);
0288 }
0289
0290 template <class _CharT, class _Traits>
0291 basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::operator<<(int __n) {
0292 return __put_num_integer_promote(__n);
0293 }
0294
0295 template <class _CharT, class _Traits>
0296 basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::operator<<(unsigned int __n) {
0297 return __put_num_integer_promote(__n);
0298 }
0299
0300 template <class _CharT, class _Traits>
0301 basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::operator<<(long __n) {
0302 return __put_num(__n);
0303 }
0304
0305 template <class _CharT, class _Traits>
0306 basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::operator<<(unsigned long __n) {
0307 return __put_num(__n);
0308 }
0309
0310 template <class _CharT, class _Traits>
0311 basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::operator<<(long long __n) {
0312 return __put_num(__n);
0313 }
0314
0315 template <class _CharT, class _Traits>
0316 basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::operator<<(unsigned long long __n) {
0317 return __put_num(__n);
0318 }
0319
0320 template <class _CharT, class _Traits>
0321 basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::operator<<(float __n) {
0322 return *this << static_cast<double>(__n);
0323 }
0324
0325 template <class _CharT, class _Traits>
0326 basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::operator<<(double __n) {
0327 return __put_num(__n);
0328 }
0329
0330 template <class _CharT, class _Traits>
0331 basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::operator<<(long double __n) {
0332 return __put_num(__n);
0333 }
0334
0335 template <class _CharT, class _Traits>
0336 basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::operator<<(const void* __n) {
0337 return __put_num(__n);
0338 }
0339
0340 template <class _CharT, class _Traits>
0341 _LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>& operator<<(basic_ostream<_CharT, _Traits>& __os, _CharT __c) {
0342 return std::__put_character_sequence(__os, &__c, 1);
0343 }
0344
0345 template <class _CharT, class _Traits>
0346 _LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>& operator<<(basic_ostream<_CharT, _Traits>& __os, char __cn) {
0347 # if _LIBCPP_HAS_EXCEPTIONS
0348 try {
0349 # endif
0350 typename basic_ostream<_CharT, _Traits>::sentry __s(__os);
0351 if (__s) {
0352 _CharT __c = __os.widen(__cn);
0353 typedef ostreambuf_iterator<_CharT, _Traits> _Ip;
0354 if (std::__pad_and_output(
0355 _Ip(__os),
0356 &__c,
0357 (__os.flags() & ios_base::adjustfield) == ios_base::left ? &__c + 1 : &__c,
0358 &__c + 1,
0359 __os,
0360 __os.fill())
0361 .failed())
0362 __os.setstate(ios_base::badbit | ios_base::failbit);
0363 }
0364 # if _LIBCPP_HAS_EXCEPTIONS
0365 } catch (...) {
0366 __os.__set_badbit_and_consider_rethrow();
0367 }
0368 # endif
0369 return __os;
0370 }
0371
0372 template <class _Traits>
0373 _LIBCPP_HIDE_FROM_ABI basic_ostream<char, _Traits>& operator<<(basic_ostream<char, _Traits>& __os, char __c) {
0374 return std::__put_character_sequence(__os, &__c, 1);
0375 }
0376
0377 template <class _Traits>
0378 _LIBCPP_HIDE_FROM_ABI basic_ostream<char, _Traits>& operator<<(basic_ostream<char, _Traits>& __os, signed char __c) {
0379 return std::__put_character_sequence(__os, (char*)&__c, 1);
0380 }
0381
0382 template <class _Traits>
0383 _LIBCPP_HIDE_FROM_ABI basic_ostream<char, _Traits>& operator<<(basic_ostream<char, _Traits>& __os, unsigned char __c) {
0384 return std::__put_character_sequence(__os, (char*)&__c, 1);
0385 }
0386
0387 template <class _CharT, class _Traits>
0388 _LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>&
0389 operator<<(basic_ostream<_CharT, _Traits>& __os, const _CharT* __str) {
0390 return std::__put_character_sequence(__os, __str, _Traits::length(__str));
0391 }
0392
0393 template <class _CharT, class _Traits>
0394 _LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>&
0395 operator<<(basic_ostream<_CharT, _Traits>& __os, const char* __strn) {
0396 # if _LIBCPP_HAS_EXCEPTIONS
0397 try {
0398 # endif
0399 typename basic_ostream<_CharT, _Traits>::sentry __s(__os);
0400 if (__s) {
0401 typedef ostreambuf_iterator<_CharT, _Traits> _Ip;
0402 size_t __len = char_traits<char>::length(__strn);
0403 const int __bs = 100;
0404 _CharT __wbb[__bs];
0405 _CharT* __wb = __wbb;
0406 unique_ptr<_CharT, void (*)(void*)> __h(0, free);
0407 if (__len > __bs) {
0408 __wb = (_CharT*)malloc(__len * sizeof(_CharT));
0409 if (__wb == 0)
0410 __throw_bad_alloc();
0411 __h.reset(__wb);
0412 }
0413 for (_CharT* __p = __wb; *__strn != '\0'; ++__strn, ++__p)
0414 *__p = __os.widen(*__strn);
0415 if (std::__pad_and_output(
0416 _Ip(__os),
0417 __wb,
0418 (__os.flags() & ios_base::adjustfield) == ios_base::left ? __wb + __len : __wb,
0419 __wb + __len,
0420 __os,
0421 __os.fill())
0422 .failed())
0423 __os.setstate(ios_base::badbit | ios_base::failbit);
0424 }
0425 # if _LIBCPP_HAS_EXCEPTIONS
0426 } catch (...) {
0427 __os.__set_badbit_and_consider_rethrow();
0428 }
0429 # endif
0430 return __os;
0431 }
0432
0433 template <class _Traits>
0434 _LIBCPP_HIDE_FROM_ABI basic_ostream<char, _Traits>& operator<<(basic_ostream<char, _Traits>& __os, const char* __str) {
0435 return std::__put_character_sequence(__os, __str, _Traits::length(__str));
0436 }
0437
0438 template <class _Traits>
0439 _LIBCPP_HIDE_FROM_ABI basic_ostream<char, _Traits>&
0440 operator<<(basic_ostream<char, _Traits>& __os, const signed char* __str) {
0441 const char* __s = (const char*)__str;
0442 return std::__put_character_sequence(__os, __s, _Traits::length(__s));
0443 }
0444
0445 template <class _Traits>
0446 _LIBCPP_HIDE_FROM_ABI basic_ostream<char, _Traits>&
0447 operator<<(basic_ostream<char, _Traits>& __os, const unsigned char* __str) {
0448 const char* __s = (const char*)__str;
0449 return std::__put_character_sequence(__os, __s, _Traits::length(__s));
0450 }
0451
0452 template <class _CharT, class _Traits>
0453 basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::put(char_type __c) {
0454 # if _LIBCPP_HAS_EXCEPTIONS
0455 try {
0456 # endif
0457 sentry __s(*this);
0458 if (__s) {
0459 typedef ostreambuf_iterator<_CharT, _Traits> _Op;
0460 _Op __o(*this);
0461 *__o = __c;
0462 if (__o.failed())
0463 this->setstate(ios_base::badbit);
0464 }
0465 # if _LIBCPP_HAS_EXCEPTIONS
0466 } catch (...) {
0467 this->__set_badbit_and_consider_rethrow();
0468 }
0469 # endif
0470 return *this;
0471 }
0472
0473 template <class _CharT, class _Traits>
0474 basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::write(const char_type* __s, streamsize __n) {
0475 # if _LIBCPP_HAS_EXCEPTIONS
0476 try {
0477 # endif
0478 sentry __sen(*this);
0479 if (__sen && __n) {
0480 if (this->rdbuf()->sputn(__s, __n) != __n)
0481 this->setstate(ios_base::badbit);
0482 }
0483 # if _LIBCPP_HAS_EXCEPTIONS
0484 } catch (...) {
0485 this->__set_badbit_and_consider_rethrow();
0486 }
0487 # endif
0488 return *this;
0489 }
0490
0491 template <class _CharT, class _Traits>
0492 basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::flush() {
0493 # if _LIBCPP_HAS_EXCEPTIONS
0494 try {
0495 # endif
0496 if (this->rdbuf()) {
0497 sentry __s(*this);
0498 if (__s) {
0499 if (this->rdbuf()->pubsync() == -1)
0500 this->setstate(ios_base::badbit);
0501 }
0502 }
0503 # if _LIBCPP_HAS_EXCEPTIONS
0504 } catch (...) {
0505 this->__set_badbit_and_consider_rethrow();
0506 }
0507 # endif
0508 return *this;
0509 }
0510
0511 template <class _CharT, class _Traits>
0512 typename basic_ostream<_CharT, _Traits>::pos_type basic_ostream<_CharT, _Traits>::tellp() {
0513 if (this->fail())
0514 return pos_type(-1);
0515 return this->rdbuf()->pubseekoff(0, ios_base::cur, ios_base::out);
0516 }
0517
0518 template <class _CharT, class _Traits>
0519 basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::seekp(pos_type __pos) {
0520 sentry __s(*this);
0521 if (!this->fail()) {
0522 if (this->rdbuf()->pubseekpos(__pos, ios_base::out) == pos_type(-1))
0523 this->setstate(ios_base::failbit);
0524 }
0525 return *this;
0526 }
0527
0528 template <class _CharT, class _Traits>
0529 basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::seekp(off_type __off, ios_base::seekdir __dir) {
0530 sentry __s(*this);
0531 if (!this->fail()) {
0532 if (this->rdbuf()->pubseekoff(__off, __dir, ios_base::out) == pos_type(-1))
0533 this->setstate(ios_base::failbit);
0534 }
0535 return *this;
0536 }
0537
0538 template <class _CharT, class _Traits>
0539 _LIBCPP_HIDE_FROM_ABI inline basic_ostream<_CharT, _Traits>& endl(basic_ostream<_CharT, _Traits>& __os) {
0540 __os.put(__os.widen('\n'));
0541 __os.flush();
0542 return __os;
0543 }
0544
0545 template <class _CharT, class _Traits>
0546 _LIBCPP_HIDE_FROM_ABI inline basic_ostream<_CharT, _Traits>& ends(basic_ostream<_CharT, _Traits>& __os) {
0547 __os.put(_CharT());
0548 return __os;
0549 }
0550
0551 template <class _CharT, class _Traits>
0552 _LIBCPP_HIDE_FROM_ABI inline basic_ostream<_CharT, _Traits>& flush(basic_ostream<_CharT, _Traits>& __os) {
0553 __os.flush();
0554 return __os;
0555 }
0556
0557 template <class _Stream, class _Tp, class = void>
0558 struct __is_ostreamable : false_type {};
0559
0560 template <class _Stream, class _Tp>
0561 struct __is_ostreamable<_Stream, _Tp, decltype(std::declval<_Stream>() << std::declval<_Tp>(), void())> : true_type {};
0562
0563 template <class _Stream,
0564 class _Tp,
0565 __enable_if_t<_And<is_base_of<ios_base, _Stream>, __is_ostreamable<_Stream&, const _Tp&> >::value, int> = 0>
0566 _LIBCPP_HIDE_FROM_ABI _Stream&& operator<<(_Stream&& __os, const _Tp& __x) {
0567 __os << __x;
0568 return std::move(__os);
0569 }
0570
0571 template <class _CharT, class _Traits, class _Allocator>
0572 basic_ostream<_CharT, _Traits>&
0573 operator<<(basic_ostream<_CharT, _Traits>& __os, const basic_string<_CharT, _Traits, _Allocator>& __str) {
0574 return std::__put_character_sequence(__os, __str.data(), __str.size());
0575 }
0576
0577 template <class _CharT, class _Traits>
0578 _LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>&
0579 operator<<(basic_ostream<_CharT, _Traits>& __os, basic_string_view<_CharT, _Traits> __sv) {
0580 return std::__put_character_sequence(__os, __sv.data(), __sv.size());
0581 }
0582
0583 template <class _CharT, class _Traits>
0584 inline _LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>&
0585 operator<<(basic_ostream<_CharT, _Traits>& __os, const error_code& __ec) {
0586 return __os << __ec.category().name() << ':' << __ec.value();
0587 }
0588
0589 template <class _CharT, class _Traits, class _Yp>
0590 inline _LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>&
0591 operator<<(basic_ostream<_CharT, _Traits>& __os, shared_ptr<_Yp> const& __p) {
0592 return __os << __p.get();
0593 }
0594
0595 template <
0596 class _CharT,
0597 class _Traits,
0598 class _Yp,
0599 class _Dp,
0600 __enable_if_t<is_same<void,
0601 __void_t<decltype((std::declval<basic_ostream<_CharT, _Traits>&>()
0602 << std::declval<typename unique_ptr<_Yp, _Dp>::pointer>()))> >::value,
0603 int> = 0>
0604 inline _LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>&
0605 operator<<(basic_ostream<_CharT, _Traits>& __os, unique_ptr<_Yp, _Dp> const& __p) {
0606 return __os << __p.get();
0607 }
0608
0609 template <class _CharT, class _Traits, size_t _Size>
0610 _LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>&
0611 operator<<(basic_ostream<_CharT, _Traits>& __os, const bitset<_Size>& __x) {
0612 return __os << __x.template to_string<_CharT, _Traits>(std::use_facet<ctype<_CharT> >(__os.getloc()).widen('0'),
0613 std::use_facet<ctype<_CharT> >(__os.getloc()).widen('1'));
0614 }
0615
0616 # if _LIBCPP_STD_VER >= 20
0617
0618 # if _LIBCPP_HAS_WIDE_CHARACTERS
0619 template <class _Traits>
0620 basic_ostream<char, _Traits>& operator<<(basic_ostream<char, _Traits>&, wchar_t) = delete;
0621
0622 template <class _Traits>
0623 basic_ostream<char, _Traits>& operator<<(basic_ostream<char, _Traits>&, const wchar_t*) = delete;
0624
0625 template <class _Traits>
0626 basic_ostream<wchar_t, _Traits>& operator<<(basic_ostream<wchar_t, _Traits>&, char16_t) = delete;
0627
0628 template <class _Traits>
0629 basic_ostream<wchar_t, _Traits>& operator<<(basic_ostream<wchar_t, _Traits>&, char32_t) = delete;
0630
0631 template <class _Traits>
0632 basic_ostream<wchar_t, _Traits>& operator<<(basic_ostream<wchar_t, _Traits>&, const char16_t*) = delete;
0633
0634 template <class _Traits>
0635 basic_ostream<wchar_t, _Traits>& operator<<(basic_ostream<wchar_t, _Traits>&, const char32_t*) = delete;
0636
0637 # endif
0638
0639 # if _LIBCPP_HAS_CHAR8_T
0640 template <class _Traits>
0641 basic_ostream<char, _Traits>& operator<<(basic_ostream<char, _Traits>&, char8_t) = delete;
0642
0643 template <class _Traits>
0644 basic_ostream<wchar_t, _Traits>& operator<<(basic_ostream<wchar_t, _Traits>&, char8_t) = delete;
0645
0646 template <class _Traits>
0647 basic_ostream<char, _Traits>& operator<<(basic_ostream<char, _Traits>&, const char8_t*) = delete;
0648
0649 template <class _Traits>
0650 basic_ostream<wchar_t, _Traits>& operator<<(basic_ostream<wchar_t, _Traits>&, const char8_t*) = delete;
0651 # endif
0652
0653 template <class _Traits>
0654 basic_ostream<char, _Traits>& operator<<(basic_ostream<char, _Traits>&, char16_t) = delete;
0655
0656 template <class _Traits>
0657 basic_ostream<char, _Traits>& operator<<(basic_ostream<char, _Traits>&, char32_t) = delete;
0658
0659 template <class _Traits>
0660 basic_ostream<char, _Traits>& operator<<(basic_ostream<char, _Traits>&, const char16_t*) = delete;
0661
0662 template <class _Traits>
0663 basic_ostream<char, _Traits>& operator<<(basic_ostream<char, _Traits>&, const char32_t*) = delete;
0664
0665 # endif
0666
0667 extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_ostream<char>;
0668 # if _LIBCPP_HAS_WIDE_CHARACTERS
0669 extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_ostream<wchar_t>;
0670 # endif
0671
0672 _LIBCPP_END_NAMESPACE_STD
0673
0674 _LIBCPP_POP_MACROS
0675
0676 #endif
0677
0678 #endif