| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
#ifndef _GLIBCXX_OSTREAM_H |
| 35 |
#define _GLIBCXX_OSTREAM_H 1 |
| 36 |
|
| 37 |
#ifdef _GLIBCXX_SYSHDR |
| 38 |
#pragma GCC system_header |
| 39 |
#endif |
| 40 |
|
| 41 |
#include <bits/requires_hosted.h> |
| 42 |
|
| 43 |
#include <ios> |
| 44 |
#include <bits/ostream_insert.h> |
| 45 |
|
| 46 |
# define __glibcxx_want_print |
| 47 |
#include <bits/version.h> |
| 48 |
|
| 49 |
namespace std _GLIBCXX_VISIBILITY(default) |
| 50 |
{ |
| 51 |
_GLIBCXX_BEGIN_NAMESPACE_VERSION |
| 52 |
|
| 53 |
|
| 54 |
|
| 55 |
|
| 56 |
|
| 57 |
|
| 58 |
|
| 59 |
|
| 60 |
|
| 61 |
|
| 62 |
|
| 63 |
|
| 64 |
|
| 65 |
template<typename _CharT, typename _Traits> |
| 66 |
class basic_ostream : virtual public basic_ios<_CharT, _Traits> |
| 67 |
{ |
| 68 |
public: |
| 69 |
|
| 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; |
| 75 |
|
| 76 |
|
| 77 |
typedef basic_streambuf<_CharT, _Traits> __streambuf_type; |
| 78 |
typedef basic_ios<_CharT, _Traits> __ios_type; |
| 79 |
typedef basic_ostream<_CharT, _Traits> __ostream_type; |
| 80 |
typedef num_put<_CharT, ostreambuf_iterator<_CharT, _Traits> > |
| 81 |
__num_put_type; |
| 82 |
typedef ctype<_CharT> __ctype_type; |
| 83 |
|
| 84 |
|
| 85 |
|
| 86 |
|
| 87 |
|
| 88 |
|
| 89 |
|
| 90 |
|
| 91 |
explicit |
| 92 |
basic_ostream(__streambuf_type* __sb) |
| 93 |
{ this->init(__sb); } |
| 94 |
|
| 95 |
|
| 96 |
|
| 97 |
|
| 98 |
|
| 99 |
|
| 100 |
virtual |
| 101 |
~basic_ostream() { } |
| 102 |
|
| 103 |
|
| 104 |
class sentry; |
| 105 |
friend class sentry; |
| 106 |
|
| 107 |
|
| 108 |
|
| 109 |
|
| 110 |
|
| 111 |
|
| 112 |
|
| 113 |
|
| 114 |
|
| 115 |
__ostream_type& |
| 116 |
operator<<(__ostream_type& (*__pf)(__ostream_type&)) |
| 117 |
{ |
| 118 |
|
| 119 |
|
| 120 |
|
| 121 |
return __pf(*this); |
| 122 |
} |
| 123 |
|
| 124 |
__ostream_type& |
| 125 |
operator<<(__ios_type& (*__pf)(__ios_type&)) |
| 126 |
{ |
| 127 |
|
| 128 |
|
| 129 |
|
| 130 |
__pf(*this); |
| 131 |
return *this; |
| 132 |
} |
| 133 |
|
| 134 |
__ostream_type& |
| 135 |
operator<<(ios_base& (*__pf) (ios_base&)) |
| 136 |
{ |
| 137 |
|
| 138 |
|
| 139 |
|
| 140 |
__pf(*this); |
| 141 |
return *this; |
| 142 |
} |
| 143 |
|
| 144 |
|
| 145 |
|
| 146 |
|
| 147 |
|
| 148 |
|
| 149 |
|
| 150 |
|
| 151 |
|
| 152 |
|
| 153 |
|
| 154 |
|
| 155 |
|
| 156 |
|
| 157 |
|
| 158 |
|
| 159 |
|
| 160 |
|
| 161 |
|
| 162 |
|
| 163 |
|
| 164 |
|
| 165 |
|
| 166 |
|
| 167 |
|
| 168 |
|
| 169 |
|
| 170 |
|
| 171 |
|
| 172 |
|
| 173 |
__ostream_type& |
| 174 |
operator<<(long __n) |
| 175 |
{ return _M_insert(__n); } |
| 176 |
|
| 177 |
__ostream_type& |
| 178 |
operator<<(unsigned long __n) |
| 179 |
{ return _M_insert(__n); } |
| 180 |
|
| 181 |
__ostream_type& |
| 182 |
operator<<(bool __n) |
| 183 |
{ return _M_insert(__n); } |
| 184 |
|
| 185 |
__ostream_type& |
| 186 |
operator<<(short __n); |
| 187 |
|
| 188 |
__ostream_type& |
| 189 |
operator<<(unsigned short __n) |
| 190 |
{ |
| 191 |
|
| 192 |
|
| 193 |
return _M_insert(static_cast<unsigned long>(__n)); |
| 194 |
} |
| 195 |
|
| 196 |
__ostream_type& |
| 197 |
operator<<(int __n); |
| 198 |
|
| 199 |
__ostream_type& |
| 200 |
operator<<(unsigned int __n) |
| 201 |
{ |
| 202 |
|
| 203 |
|
| 204 |
return _M_insert(static_cast<unsigned long>(__n)); |
| 205 |
} |
| 206 |
|
| 207 |
#ifdef _GLIBCXX_USE_LONG_LONG |
| 208 |
#pragma GCC diagnostic push |
| 209 |
#pragma GCC diagnostic ignored "-Wlong-long" |
| 210 |
__ostream_type& |
| 211 |
operator<<(long long __n) |
| 212 |
{ return _M_insert(__n); } |
| 213 |
|
| 214 |
__ostream_type& |
| 215 |
operator<<(unsigned long long __n) |
| 216 |
{ return _M_insert(__n); } |
| 217 |
#pragma GCC diagnostic pop |
| 218 |
#endif |
| 219 |
|
| 220 |
|
| 221 |
|
| 222 |
|
| 223 |
|
| 224 |
|
| 225 |
|
| 226 |
|
| 227 |
|
| 228 |
|
| 229 |
|
| 230 |
__ostream_type& |
| 231 |
operator<<(double __f) |
| 232 |
{ return _M_insert(__f); } |
| 233 |
|
| 234 |
__ostream_type& |
| 235 |
operator<<(float __f) |
| 236 |
{ |
| 237 |
|
| 238 |
|
| 239 |
return _M_insert(_S_cast_flt<double>(__f)); |
| 240 |
} |
| 241 |
|
| 242 |
__ostream_type& |
| 243 |
operator<<(long double __f) |
| 244 |
{ return _M_insert(__f); } |
| 245 |
|
| 246 |
|
| 247 |
#if defined(__STDCPP_FLOAT16_T__) && defined(_GLIBCXX_DOUBLE_IS_IEEE_BINARY64) |
| 248 |
__attribute__((__always_inline__)) |
| 249 |
__ostream_type& |
| 250 |
operator<<(_Float16 __f) |
| 251 |
{ |
| 252 |
return _M_insert(_S_cast_flt<double>(__f)); |
| 253 |
} |
| 254 |
#endif |
| 255 |
|
| 256 |
#if defined(__STDCPP_FLOAT32_T__) && defined(_GLIBCXX_DOUBLE_IS_IEEE_BINARY64) |
| 257 |
__attribute__((__always_inline__)) |
| 258 |
__ostream_type& |
| 259 |
operator<<(_Float32 __f) |
| 260 |
{ |
| 261 |
return _M_insert(_S_cast_flt<double>(__f)); |
| 262 |
} |
| 263 |
#endif |
| 264 |
|
| 265 |
#if defined(__STDCPP_FLOAT64_T__) && defined(_GLIBCXX_DOUBLE_IS_IEEE_BINARY64) |
| 266 |
__attribute__((__always_inline__)) |
| 267 |
__ostream_type& |
| 268 |
operator<<(_Float64 __f) |
| 269 |
{ |
| 270 |
return _M_insert(_S_cast_flt<double>(__f)); |
| 271 |
} |
| 272 |
#endif |
| 273 |
|
| 274 |
#if defined(__STDCPP_FLOAT128_T__) && defined(_GLIBCXX_LDOUBLE_IS_IEEE_BINARY128) |
| 275 |
__attribute__((__always_inline__)) |
| 276 |
__ostream_type& |
| 277 |
operator<<(_Float128 __f) |
| 278 |
{ |
| 279 |
return _M_insert(_S_cast_flt<long double>(__f)); |
| 280 |
} |
| 281 |
#endif |
| 282 |
|
| 283 |
#if defined(__STDCPP_BFLOAT16_T__) && defined(_GLIBCXX_DOUBLE_IS_IEEE_BINARY64) |
| 284 |
__attribute__((__always_inline__)) |
| 285 |
__ostream_type& |
| 286 |
operator<<(__gnu_cxx::__bfloat16_t __f) |
| 287 |
{ |
| 288 |
return _M_insert(_S_cast_flt<double>(__f)); |
| 289 |
} |
| 290 |
#endif |
| 291 |
|
| 292 |
|
| 293 |
|
| 294 |
|
| 295 |
|
| 296 |
|
| 297 |
|
| 298 |
|
| 299 |
|
| 300 |
__ostream_type& |
| 301 |
operator<<(const void* __p) |
| 302 |
{ return _M_insert(__p); } |
| 303 |
|
| 304 |
#if __cplusplus >= 201703L |
| 305 |
__ostream_type& |
| 306 |
operator<<(nullptr_t) |
| 307 |
{ return *this << "nullptr"; } |
| 308 |
#endif |
| 309 |
|
| 310 |
#if __cplusplus > 202002L |
| 311 |
__attribute__((__always_inline__)) |
| 312 |
__ostream_type& |
| 313 |
operator<<(const volatile void* __p) |
| 314 |
{ return _M_insert(const_cast<const void*>(__p)); } |
| 315 |
#endif |
| 316 |
|
| 317 |
|
| 318 |
|
| 319 |
|
| 320 |
|
| 321 |
|
| 322 |
|
| 323 |
|
| 324 |
|
| 325 |
|
| 326 |
|
| 327 |
|
| 328 |
|
| 329 |
|
| 330 |
|
| 331 |
|
| 332 |
|
| 333 |
|
| 334 |
|
| 335 |
|
| 336 |
|
| 337 |
|
| 338 |
__ostream_type& |
| 339 |
operator<<(__streambuf_type* __sb); |
| 340 |
|
| 341 |
|
| 342 |
|
| 343 |
|
| 344 |
|
| 345 |
|
| 346 |
|
| 347 |
|
| 348 |
|
| 349 |
|
| 350 |
|
| 351 |
|
| 352 |
|
| 353 |
|
| 354 |
|
| 355 |
|
| 356 |
|
| 357 |
|
| 358 |
|
| 359 |
|
| 360 |
|
| 361 |
|
| 362 |
|
| 363 |
|
| 364 |
|
| 365 |
|
| 366 |
|
| 367 |
|
| 368 |
|
| 369 |
|
| 370 |
|
| 371 |
__ostream_type& |
| 372 |
put(char_type __c); |
| 373 |
|
| 374 |
|
| 375 |
|
| 376 |
|
| 377 |
|
| 378 |
|
| 379 |
|
| 380 |
|
| 381 |
|
| 382 |
|
| 383 |
|
| 384 |
|
| 385 |
|
| 386 |
|
| 387 |
|
| 388 |
|
| 389 |
|
| 390 |
__ostream_type& |
| 391 |
write(const char_type* __s, streamsize __n); |
| 392 |
|
| 393 |
|
| 394 |
|
| 395 |
|
| 396 |
|
| 397 |
|
| 398 |
|
| 399 |
|
| 400 |
|
| 401 |
|
| 402 |
|
| 403 |
__ostream_type& |
| 404 |
flush(); |
| 405 |
|
| 406 |
|
| 407 |
|
| 408 |
|
| 409 |
|
| 410 |
|
| 411 |
|
| 412 |
|
| 413 |
pos_type |
| 414 |
tellp(); |
| 415 |
|
| 416 |
|
| 417 |
|
| 418 |
|
| 419 |
|
| 420 |
|
| 421 |
|
| 422 |
|
| 423 |
|
| 424 |
__ostream_type& |
| 425 |
seekp(pos_type); |
| 426 |
|
| 427 |
|
| 428 |
|
| 429 |
|
| 430 |
|
| 431 |
|
| 432 |
|
| 433 |
|
| 434 |
|
| 435 |
|
| 436 |
__ostream_type& |
| 437 |
seekp(off_type, ios_base::seekdir); |
| 438 |
|
| 439 |
protected: |
| 440 |
basic_ostream() |
| 441 |
{ this->init(0); } |
| 442 |
|
| 443 |
#if __cplusplus >= 201103L |
| 444 |
|
| 445 |
basic_ostream(basic_iostream<_CharT, _Traits>&) { } |
| 446 |
|
| 447 |
basic_ostream(const basic_ostream&) = delete; |
| 448 |
|
| 449 |
basic_ostream(basic_ostream&& __rhs) |
| 450 |
: __ios_type() |
| 451 |
{ __ios_type::move(__rhs); } |
| 452 |
|
| 453 |
|
| 454 |
|
| 455 |
basic_ostream& operator=(const basic_ostream&) = delete; |
| 456 |
|
| 457 |
basic_ostream& |
| 458 |
operator=(basic_ostream&& __rhs) |
| 459 |
{ |
| 460 |
swap(__rhs); |
| 461 |
return *this; |
| 462 |
} |
| 463 |
|
| 464 |
void |
| 465 |
swap(basic_ostream& __rhs) |
| 466 |
{ __ios_type::swap(__rhs); } |
| 467 |
#endif |
| 468 |
|
| 469 |
template<typename _ValueT> |
| 470 |
__ostream_type& |
| 471 |
_M_insert(_ValueT __v); |
| 472 |
|
| 473 |
private: |
| 474 |
#if !_GLIBCXX_INLINE_VERSION |
| 475 |
void |
| 476 |
_M_write(const char_type* __s, streamsize __n) |
| 477 |
{ std::__ostream_insert(*this, __s, __n); } |
| 478 |
#endif |
| 479 |
|
| 480 |
#pragma GCC diagnostic push |
| 481 |
#pragma GCC diagnostic ignored "-Wc++17-extensions" // for if-constexpr |
| 482 |
template<typename _To, typename _From> |
| 483 |
static _To |
| 484 |
_S_cast_flt(_From __f) |
| 485 |
{ |
| 486 |
_To __d = static_cast<_To>(__f); |
| 487 |
|
| 488 |
|
| 489 |
#if defined __riscv |
| 490 |
_To __sign; |
| 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)); |
| 498 |
else |
| 499 |
#endif |
| 500 |
__sign = __builtin_signbit(__f) ? _To(-1.0) : _To(+1.0); |
| 501 |
|
| 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); |
| 506 |
#endif |
| 507 |
return __d; |
| 508 |
} |
| 509 |
#pragma GCC diagnostic pop |
| 510 |
|
| 511 |
|
| 512 |
struct _Disable_exceptions |
| 513 |
{ |
| 514 |
_Disable_exceptions(basic_ostream& __os) |
| 515 |
: _M_os(__os), _M_exception(_M_os._M_exception) |
| 516 |
{ _M_os._M_exception = ios_base::goodbit; } |
| 517 |
|
| 518 |
~_Disable_exceptions() |
| 519 |
{ _M_os._M_exception = _M_exception; } |
| 520 |
|
| 521 |
#pragma GCC diagnostic push |
| 522 |
#pragma GCC diagnostic ignored "-Wc++11-extensions" // deleted functions |
| 523 |
_Disable_exceptions(const _Disable_exceptions&) = delete; |
| 524 |
_Disable_exceptions& operator=(const _Disable_exceptions&) = delete; |
| 525 |
#pragma GCC diagnostic pop |
| 526 |
|
| 527 |
private: |
| 528 |
basic_ostream& _M_os; |
| 529 |
const ios_base::iostate _M_exception; |
| 530 |
}; |
| 531 |
}; |
| 532 |
|
| 533 |
|
| 534 |
|
| 535 |
|
| 536 |
|
| 537 |
|
| 538 |
|
| 539 |
|
| 540 |
template <typename _CharT, typename _Traits> |
| 541 |
class basic_ostream<_CharT, _Traits>::sentry |
| 542 |
{ |
| 543 |
|
| 544 |
bool _M_ok; |
| 545 |
basic_ostream<_CharT, _Traits>& _M_os; |
| 546 |
|
| 547 |
public: |
| 548 |
|
| 549 |
|
| 550 |
|
| 551 |
|
| 552 |
|
| 553 |
|
| 554 |
|
| 555 |
|
| 556 |
|
| 557 |
|
| 558 |
|
| 559 |
explicit |
| 560 |
sentry(basic_ostream<_CharT, _Traits>& __os); |
| 561 |
|
| 562 |
#pragma GCC diagnostic push |
| 563 |
#pragma GCC diagnostic ignored "-Wdeprecated-declarations" |
| 564 |
|
| 565 |
|
| 566 |
|
| 567 |
|
| 568 |
|
| 569 |
|
| 570 |
|
| 571 |
~sentry() |
| 572 |
{ |
| 573 |
|
| 574 |
|
| 575 |
|
| 576 |
|
| 577 |
if (bool(_M_os.flags() & ios_base::unitbuf) && _M_os.good() |
| 578 |
&& !uncaught_exception()) |
| 579 |
{ |
| 580 |
_Disable_exceptions __noex(_M_os); |
| 581 |
__try |
| 582 |
{ |
| 583 |
|
| 584 |
|
| 585 |
if (_M_os.rdbuf() && _M_os.rdbuf()->pubsync() == -1) |
| 586 |
_M_os.setstate(ios_base::badbit); |
| 587 |
} |
| 588 |
__catch(...) |
| 589 |
{ _M_os.setstate(ios_base::badbit); } |
| 590 |
} |
| 591 |
} |
| 592 |
#pragma GCC diagnostic pop |
| 593 |
|
| 594 |
|
| 595 |
|
| 596 |
|
| 597 |
|
| 598 |
|
| 599 |
|
| 600 |
|
| 601 |
#if __cplusplus >= 201103L |
| 602 |
explicit |
| 603 |
#endif |
| 604 |
operator bool() const |
| 605 |
{ return _M_ok; } |
| 606 |
}; |
| 607 |
|
| 608 |
|
| 609 |
|
| 610 |
|
| 611 |
|
| 612 |
|
| 613 |
|
| 614 |
|
| 615 |
|
| 616 |
|
| 617 |
|
| 618 |
|
| 619 |
|
| 620 |
|
| 621 |
|
| 622 |
|
| 623 |
|
| 624 |
template<typename _CharT, typename _Traits> |
| 625 |
inline basic_ostream<_CharT, _Traits>& |
| 626 |
operator<<(basic_ostream<_CharT, _Traits>& __out, _CharT __c) |
| 627 |
{ |
| 628 |
if (__out.width() != 0) |
| 629 |
return __ostream_insert(__out, &__c, 1); |
| 630 |
__out.put(__c); |
| 631 |
return __out; |
| 632 |
} |
| 633 |
|
| 634 |
template<typename _CharT, typename _Traits> |
| 635 |
inline basic_ostream<_CharT, _Traits>& |
| 636 |
operator<<(basic_ostream<_CharT, _Traits>& __out, char __c) |
| 637 |
{ return (__out << __out.widen(__c)); } |
| 638 |
|
| 639 |
|
| 640 |
template<typename _Traits> |
| 641 |
inline basic_ostream<char, _Traits>& |
| 642 |
operator<<(basic_ostream<char, _Traits>& __out, char __c) |
| 643 |
{ |
| 644 |
if (__out.width() != 0) |
| 645 |
return __ostream_insert(__out, &__c, 1); |
| 646 |
__out.put(__c); |
| 647 |
return __out; |
| 648 |
} |
| 649 |
|
| 650 |
|
| 651 |
template<typename _Traits> |
| 652 |
inline basic_ostream<char, _Traits>& |
| 653 |
operator<<(basic_ostream<char, _Traits>& __out, signed char __c) |
| 654 |
{ return (__out << static_cast<char>(__c)); } |
| 655 |
|
| 656 |
template<typename _Traits> |
| 657 |
inline basic_ostream<char, _Traits>& |
| 658 |
operator<<(basic_ostream<char, _Traits>& __out, unsigned char __c) |
| 659 |
{ return (__out << static_cast<char>(__c)); } |
| 660 |
|
| 661 |
#if __cplusplus > 201703L |
| 662 |
|
| 663 |
|
| 664 |
|
| 665 |
template<typename _Traits> |
| 666 |
basic_ostream<char, _Traits>& |
| 667 |
operator<<(basic_ostream<char, _Traits>&, wchar_t) = delete; |
| 668 |
|
| 669 |
#ifdef _GLIBCXX_USE_CHAR8_T |
| 670 |
template<typename _Traits> |
| 671 |
basic_ostream<char, _Traits>& |
| 672 |
operator<<(basic_ostream<char, _Traits>&, char8_t) = delete; |
| 673 |
#endif |
| 674 |
|
| 675 |
template<typename _Traits> |
| 676 |
basic_ostream<char, _Traits>& |
| 677 |
operator<<(basic_ostream<char, _Traits>&, char16_t) = delete; |
| 678 |
|
| 679 |
template<typename _Traits> |
| 680 |
basic_ostream<char, _Traits>& |
| 681 |
operator<<(basic_ostream<char, _Traits>&, char32_t) = delete; |
| 682 |
|
| 683 |
#ifdef _GLIBCXX_USE_WCHAR_T |
| 684 |
#ifdef _GLIBCXX_USE_CHAR8_T |
| 685 |
template<typename _Traits> |
| 686 |
basic_ostream<wchar_t, _Traits>& |
| 687 |
operator<<(basic_ostream<wchar_t, _Traits>&, char8_t) = delete; |
| 688 |
#endif |
| 689 |
|
| 690 |
template<typename _Traits> |
| 691 |
basic_ostream<wchar_t, _Traits>& |
| 692 |
operator<<(basic_ostream<wchar_t, _Traits>&, char16_t) = delete; |
| 693 |
|
| 694 |
template<typename _Traits> |
| 695 |
basic_ostream<wchar_t, _Traits>& |
| 696 |
operator<<(basic_ostream<wchar_t, _Traits>&, char32_t) = delete; |
| 697 |
#endif |
| 698 |
#endif |
| 699 |
|
| 700 |
|
| 701 |
|
| 702 |
|
| 703 |
|
| 704 |
|
| 705 |
|
| 706 |
|
| 707 |
|
| 708 |
|
| 709 |
|
| 710 |
|
| 711 |
|
| 712 |
|
| 713 |
|
| 714 |
|
| 715 |
template<typename _CharT, typename _Traits> |
| 716 |
inline basic_ostream<_CharT, _Traits>& |
| 717 |
operator<<(basic_ostream<_CharT, _Traits>& __out, const _CharT* __s) |
| 718 |
{ |
| 719 |
if (!__s) |
| 720 |
__out.setstate(ios_base::badbit); |
| 721 |
else |
| 722 |
__ostream_insert(__out, __s, |
| 723 |
static_cast<streamsize>(_Traits::length(__s))); |
| 724 |
return __out; |
| 725 |
} |
| 726 |
|
| 727 |
template<typename _CharT, typename _Traits> |
| 728 |
basic_ostream<_CharT, _Traits> & |
| 729 |
operator<<(basic_ostream<_CharT, _Traits>& __out, const char* __s); |
| 730 |
|
| 731 |
|
| 732 |
template<typename _Traits> |
| 733 |
inline basic_ostream<char, _Traits>& |
| 734 |
operator<<(basic_ostream<char, _Traits>& __out, const char* __s) |
| 735 |
{ |
| 736 |
if (!__s) |
| 737 |
__out.setstate(ios_base::badbit); |
| 738 |
else |
| 739 |
__ostream_insert(__out, __s, |
| 740 |
static_cast<streamsize>(_Traits::length(__s))); |
| 741 |
return __out; |
| 742 |
} |
| 743 |
|
| 744 |
|
| 745 |
template<typename _Traits> |
| 746 |
inline basic_ostream<char, _Traits>& |
| 747 |
operator<<(basic_ostream<char, _Traits>& __out, const signed char* __s) |
| 748 |
{ return (__out << reinterpret_cast<const char*>(__s)); } |
| 749 |
|
| 750 |
template<typename _Traits> |
| 751 |
inline basic_ostream<char, _Traits> & |
| 752 |
operator<<(basic_ostream<char, _Traits>& __out, const unsigned char* __s) |
| 753 |
{ return (__out << reinterpret_cast<const char*>(__s)); } |
| 754 |
|
| 755 |
#if __cplusplus > 201703L |
| 756 |
|
| 757 |
|
| 758 |
|
| 759 |
template<typename _Traits> |
| 760 |
basic_ostream<char, _Traits>& |
| 761 |
operator<<(basic_ostream<char, _Traits>&, const wchar_t*) = delete; |
| 762 |
|
| 763 |
#ifdef _GLIBCXX_USE_CHAR8_T |
| 764 |
template<typename _Traits> |
| 765 |
basic_ostream<char, _Traits>& |
| 766 |
operator<<(basic_ostream<char, _Traits>&, const char8_t*) = delete; |
| 767 |
#endif |
| 768 |
|
| 769 |
template<typename _Traits> |
| 770 |
basic_ostream<char, _Traits>& |
| 771 |
operator<<(basic_ostream<char, _Traits>&, const char16_t*) = delete; |
| 772 |
|
| 773 |
template<typename _Traits> |
| 774 |
basic_ostream<char, _Traits>& |
| 775 |
operator<<(basic_ostream<char, _Traits>&, const char32_t*) = delete; |
| 776 |
|
| 777 |
#ifdef _GLIBCXX_USE_WCHAR_T |
| 778 |
#ifdef _GLIBCXX_USE_CHAR8_T |
| 779 |
template<typename _Traits> |
| 780 |
basic_ostream<wchar_t, _Traits>& |
| 781 |
operator<<(basic_ostream<wchar_t, _Traits>&, const char8_t*) = delete; |
| 782 |
#endif |
| 783 |
|
| 784 |
template<typename _Traits> |
| 785 |
basic_ostream<wchar_t, _Traits>& |
| 786 |
operator<<(basic_ostream<wchar_t, _Traits>&, const char16_t*) = delete; |
| 787 |
|
| 788 |
template<typename _Traits> |
| 789 |
basic_ostream<wchar_t, _Traits>& |
| 790 |
operator<<(basic_ostream<wchar_t, _Traits>&, const char32_t*) = delete; |
| 791 |
#endif |
| 792 |
#endif |
| 793 |
|
| 794 |
|
| 795 |
#if __cplusplus >= 201103L |
| 796 |
|
| 797 |
|
| 798 |
|
| 799 |
|
| 800 |
#if __cpp_concepts >= 201907L && __glibcxx_type_trait_variable_templates |
| 801 |
|
| 802 |
template<typename _Tp> |
| 803 |
concept __derived_from_ios_base = is_class_v<_Tp> |
| 804 |
&& (!is_same_v<_Tp, ios_base>) |
| 805 |
&& requires (_Tp* __t, ios_base* __b) { __b = __t; }; |
| 806 |
|
| 807 |
template<typename _Os, typename _Tp> |
| 808 |
requires __derived_from_ios_base<_Os> |
| 809 |
&& requires (_Os& __os, const _Tp& __t) { __os << __t; } |
| 810 |
using __rvalue_stream_insertion_t = _Os&&; |
| 811 |
#else |
| 812 |
template<typename _Tp> |
| 813 |
using _Require_derived_from_ios_base |
| 814 |
= _Require<is_class<_Tp>, __not_<is_same<_Tp, ios_base>>, |
| 815 |
is_convertible<typename add_pointer<_Tp>::type, ios_base*>>; |
| 816 |
|
| 817 |
template<typename _Os, typename _Tp, |
| 818 |
typename = _Require_derived_from_ios_base<_Os>, |
| 819 |
typename |
| 820 |
= decltype(std::declval<_Os&>() << std::declval<const _Tp&>())> |
| 821 |
using __rvalue_stream_insertion_t = _Os&&; |
| 822 |
#endif |
| 823 |
|
| 824 |
|
| 825 |
|
| 826 |
|
| 827 |
|
| 828 |
|
| 829 |
|
| 830 |
|
| 831 |
|
| 832 |
|
| 833 |
|
| 834 |
template<typename _Ostream, typename _Tp> |
| 835 |
inline __rvalue_stream_insertion_t<_Ostream, _Tp> |
| 836 |
operator<<(_Ostream&& __os, const _Tp& __x) |
| 837 |
{ |
| 838 |
__os << __x; |
| 839 |
return std::move(__os); |
| 840 |
} |
| 841 |
#endif |
| 842 |
|
| 843 |
_GLIBCXX_END_NAMESPACE_VERSION |
| 844 |
} |
| 845 |
|
| 846 |
#endif |