- tmp/tmp9uwic4ig/{from.md → to.md} +139 -54
tmp/tmp9uwic4ig/{from.md → to.md}
RENAMED
|
@@ -9,22 +9,22 @@ that inserts into stream rvalues.
|
|
| 9 |
``` cpp
|
| 10 |
namespace std {
|
| 11 |
template<class charT, class traits = char_traits<charT>>
|
| 12 |
class basic_ostream : virtual public basic_ios<charT, traits> {
|
| 13 |
public:
|
| 14 |
-
// types (inherited from basic_ios
|
| 15 |
using char_type = charT;
|
| 16 |
using int_type = typename traits::int_type;
|
| 17 |
using pos_type = typename traits::pos_type;
|
| 18 |
using off_type = typename traits::off_type;
|
| 19 |
using traits_type = traits;
|
| 20 |
|
| 21 |
// [ostream.cons], constructor/destructor
|
| 22 |
explicit basic_ostream(basic_streambuf<char_type, traits>* sb);
|
| 23 |
virtual ~basic_ostream();
|
| 24 |
|
| 25 |
-
// [ostream
|
| 26 |
class sentry;
|
| 27 |
|
| 28 |
// [ostream.formatted], formatted output
|
| 29 |
basic_ostream<charT, traits>&
|
| 30 |
operator<<(basic_ostream<charT, traits>& (*pf)(basic_ostream<charT, traits>&));
|
|
@@ -61,15 +61,15 @@ namespace std {
|
|
| 61 |
basic_ostream<charT, traits>& seekp(pos_type);
|
| 62 |
basic_ostream<charT, traits>& seekp(off_type, ios_base::seekdir);
|
| 63 |
|
| 64 |
protected:
|
| 65 |
// [ostream.cons], copy/move constructor
|
| 66 |
-
basic_ostream(const basic_ostream&
|
| 67 |
basic_ostream(basic_ostream&& rhs);
|
| 68 |
|
| 69 |
// [ostream.assign], assign and swap
|
| 70 |
-
basic_ostream& operator=(const basic_ostream&
|
| 71 |
basic_ostream& operator=(basic_ostream&& rhs);
|
| 72 |
void swap(basic_ostream& rhs);
|
| 73 |
};
|
| 74 |
|
| 75 |
// [ostream.inserters.character], character inserters
|
|
@@ -83,10 +83,28 @@ namespace std {
|
|
| 83 |
template<class traits>
|
| 84 |
basic_ostream<char, traits>& operator<<(basic_ostream<char, traits>&, signed char);
|
| 85 |
template<class traits>
|
| 86 |
basic_ostream<char, traits>& operator<<(basic_ostream<char, traits>&, unsigned char);
|
| 87 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 88 |
template<class charT, class traits>
|
| 89 |
basic_ostream<charT, traits>& operator<<(basic_ostream<charT, traits>&, const charT*);
|
| 90 |
template<class charT, class traits>
|
| 91 |
basic_ostream<charT, traits>& operator<<(basic_ostream<charT, traits>&, const char*);
|
| 92 |
template<class traits>
|
|
@@ -94,10 +112,32 @@ namespace std {
|
|
| 94 |
|
| 95 |
template<class traits>
|
| 96 |
basic_ostream<char, traits>& operator<<(basic_ostream<char, traits>&, const signed char*);
|
| 97 |
template<class traits>
|
| 98 |
basic_ostream<char, traits>& operator<<(basic_ostream<char, traits>&, const unsigned char*);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 99 |
}
|
| 100 |
```
|
| 101 |
|
| 102 |
The class template `basic_ostream` defines a number of member function
|
| 103 |
signatures that assist in formatting and writing output to output
|
|
@@ -110,26 +150,29 @@ output functions.* Both groups of output functions generate (or
|
|
| 110 |
`rdbuf()->sputc(int_type)`. They may use other public members of
|
| 111 |
`basic_ostream` except that they shall not invoke any virtual members of
|
| 112 |
`rdbuf()` except `overflow()`, `xsputn()`, and `sync()`.
|
| 113 |
|
| 114 |
If one of these called functions throws an exception, then unless
|
| 115 |
-
explicitly noted otherwise the output function sets `badbit` in
|
| 116 |
-
state. If `badbit` is
|
| 117 |
-
the exception without completing its actions, otherwise it does
|
| 118 |
-
throw anything and
|
|
|
|
| 119 |
|
| 120 |
-
|
|
|
|
|
|
|
|
|
|
| 121 |
|
| 122 |
``` cpp
|
| 123 |
explicit basic_ostream(basic_streambuf<charT, traits>* sb);
|
| 124 |
```
|
| 125 |
|
| 126 |
-
*Effects:*
|
| 127 |
-
|
| 128 |
-
`basic_ios<charT, traits>::init(sb)` ([[basic.ios.cons]]).
|
| 129 |
|
| 130 |
-
*
|
| 131 |
|
| 132 |
``` cpp
|
| 133 |
basic_ostream(basic_ostream&& rhs);
|
| 134 |
```
|
| 135 |
|
|
@@ -139,31 +182,29 @@ by default constructing the base class and calling
|
|
| 139 |
|
| 140 |
``` cpp
|
| 141 |
virtual ~basic_ostream();
|
| 142 |
```
|
| 143 |
|
| 144 |
-
*Effects:* Destroys an object of class `basic_ostream`.
|
| 145 |
-
|
| 146 |
*Remarks:* Does not perform any operations on `rdbuf()`.
|
| 147 |
|
| 148 |
-
#####
|
| 149 |
|
| 150 |
``` cpp
|
| 151 |
basic_ostream& operator=(basic_ostream&& rhs);
|
| 152 |
```
|
| 153 |
|
| 154 |
-
*Effects:*
|
| 155 |
|
| 156 |
*Returns:* `*this`.
|
| 157 |
|
| 158 |
``` cpp
|
| 159 |
void swap(basic_ostream& rhs);
|
| 160 |
```
|
| 161 |
|
| 162 |
*Effects:* Calls `basic_ios<charT, traits>::swap(rhs)`.
|
| 163 |
|
| 164 |
-
##### Class `basic_ostream::sentry` <a id="ostream
|
| 165 |
|
| 166 |
``` cpp
|
| 167 |
namespace std {
|
| 168 |
template<class charT, class traits = char_traits<charT>>
|
| 169 |
class basic_ostream<charT, traits>::sentry {
|
|
@@ -190,11 +231,11 @@ If `os.good()` is nonzero, prepares for formatted or unformatted output.
|
|
| 190 |
If `os.tie()` is not a null pointer, calls `os.tie()->flush()`.[^31]
|
| 191 |
|
| 192 |
If, after any preparation is completed, `os.good()` is `true`,
|
| 193 |
`ok_ == true` otherwise, `ok_ == false`. During preparation, the
|
| 194 |
constructor may call `setstate(failbit)` (which may throw
|
| 195 |
-
`ios_base::failure`
|
| 196 |
|
| 197 |
``` cpp
|
| 198 |
~sentry();
|
| 199 |
```
|
| 200 |
|
|
@@ -207,11 +248,11 @@ sets `badbit` in `os.rdstate()` without propagating an exception.
|
|
| 207 |
explicit operator bool() const;
|
| 208 |
```
|
| 209 |
|
| 210 |
*Effects:* Returns `ok_`.
|
| 211 |
|
| 212 |
-
#####
|
| 213 |
|
| 214 |
Each seek member function begins execution by constructing an object of
|
| 215 |
class `sentry`. It returns by destroying the `sentry` object.
|
| 216 |
|
| 217 |
``` cpp
|
|
@@ -250,12 +291,12 @@ function calls `setstate(failbit)` (which may throw
|
|
| 250 |
Each formatted output function begins execution by constructing an
|
| 251 |
object of class `sentry`. If this object returns `true` when converted
|
| 252 |
to a value of type `bool`, the function endeavors to generate the
|
| 253 |
requested output. If the generation fails, then the formatted output
|
| 254 |
function does `setstate(ios_base::failbit)`, which might throw an
|
| 255 |
-
exception. If an exception is thrown during output, then
|
| 256 |
-
is turned on[^33] in `*this`’s error state. If
|
| 257 |
`(exceptions()&badbit) != 0` then the exception is rethrown. Whether or
|
| 258 |
not an exception is thrown, the `sentry` object is destroyed before
|
| 259 |
leaving the formatted output function. If no exception is thrown, the
|
| 260 |
result of the formatted output function is `*this`.
|
| 261 |
|
|
@@ -396,13 +437,13 @@ in [[ostream.formatted.reqmts]]).
|
|
| 396 |
|
| 397 |
``` cpp
|
| 398 |
basic_ostream<charT, traits>& operator<<(basic_streambuf<charT, traits>* sb);
|
| 399 |
```
|
| 400 |
|
| 401 |
-
*Effects:* Behaves as an unformatted output
|
| 402 |
-
|
| 403 |
-
`sb` is null calls `setstate(badbit)` (which may throw
|
| 404 |
`ios_base::failure`).
|
| 405 |
|
| 406 |
Gets characters from `sb` and inserts them in `*this`. Characters are
|
| 407 |
read from `sb` and inserted until any of the following occurs:
|
| 408 |
|
|
@@ -410,14 +451,14 @@ read from `sb` and inserted until any of the following occurs:
|
|
| 410 |
- inserting in the output sequence fails (in which case the character to
|
| 411 |
be inserted is not extracted);
|
| 412 |
- an exception occurs while getting a character from `sb`.
|
| 413 |
|
| 414 |
If the function inserts no characters, it calls `setstate(failbit)`
|
| 415 |
-
(which may throw `ios_base::failure`
|
| 416 |
-
|
| 417 |
-
|
| 418 |
-
|
| 419 |
|
| 420 |
*Returns:* `*this`.
|
| 421 |
|
| 422 |
``` cpp
|
| 423 |
basic_ostream<charT, traits>& operator<<(nullptr_t);
|
|
@@ -427,11 +468,11 @@ basic_ostream<charT, traits>& operator<<(nullptr_t);
|
|
| 427 |
|
| 428 |
``` cpp
|
| 429 |
return *this << s;
|
| 430 |
```
|
| 431 |
|
| 432 |
-
where `s` is an *implementation-defined* NTCTS
|
| 433 |
|
| 434 |
##### Character inserter function templates <a id="ostream.inserters.character">[[ostream.inserters.character]]</a>
|
| 435 |
|
| 436 |
``` cpp
|
| 437 |
template<class charT, class traits>
|
|
@@ -447,16 +488,16 @@ template<class traits>
|
|
| 447 |
template<class traits>
|
| 448 |
basic_ostream<char, traits>& operator<<(basic_ostream<char, traits>& out, unsigned char c);
|
| 449 |
```
|
| 450 |
|
| 451 |
*Effects:* Behaves as a formatted output
|
| 452 |
-
function
|
| 453 |
-
|
| 454 |
-
|
| 455 |
-
|
| 456 |
-
|
| 457 |
-
|
| 458 |
|
| 459 |
*Returns:* `out`.
|
| 460 |
|
| 461 |
``` cpp
|
| 462 |
template<class charT, class traits>
|
|
@@ -470,17 +511,17 @@ template<class traits>
|
|
| 470 |
template<class traits>
|
| 471 |
basic_ostream<char, traits>& operator<<(basic_ostream<char, traits>& out,
|
| 472 |
const unsigned char* s);
|
| 473 |
```
|
| 474 |
|
| 475 |
-
*
|
| 476 |
|
| 477 |
*Effects:* Behaves like a formatted inserter (as described
|
| 478 |
in [[ostream.formatted.reqmts]]) of `out`. Creates a character sequence
|
| 479 |
`seq` of `n` characters starting at `s`, each widened using
|
| 480 |
-
`out.widen()`
|
| 481 |
-
|
| 482 |
|
| 483 |
- `traits::length(s)` for the overload where the first argument is of
|
| 484 |
type `basic_ostream<charT, traits>&` and the second is of type
|
| 485 |
`const charT*`, and also for the overload where the first argument is
|
| 486 |
of type `basic_ostream<char, traits>&` and the second is of type
|
|
@@ -501,11 +542,11 @@ in [[ostream.formatted.reqmts]]. Inserts `seq` into `out`. Calls
|
|
| 501 |
|
| 502 |
Each unformatted output function begins execution by constructing an
|
| 503 |
object of class `sentry`. If this object returns `true`, while
|
| 504 |
converting to a value of type `bool`, the function endeavors to generate
|
| 505 |
the requested output. If an exception is thrown during output, then
|
| 506 |
-
`
|
| 507 |
`(exceptions() & badbit) != 0` then the exception is rethrown. In any
|
| 508 |
case, the unformatted output function ends by destroying the sentry
|
| 509 |
object, then, if no exception was thrown, returning the value specified
|
| 510 |
for the unformatted output function.
|
| 511 |
|
|
@@ -515,12 +556,12 @@ basic_ostream<charT, traits>& put(char_type c);
|
|
| 515 |
|
| 516 |
*Effects:* Behaves as an unformatted output function (as described
|
| 517 |
above). After constructing a sentry object, inserts the character `c`,
|
| 518 |
if possible.[^37]
|
| 519 |
|
| 520 |
-
Otherwise, calls `setstate(badbit)` (which may throw
|
| 521 |
-
|
| 522 |
|
| 523 |
*Returns:* `*this`.
|
| 524 |
|
| 525 |
``` cpp
|
| 526 |
basic_ostream& write(const char_type* s, streamsize n);
|
|
@@ -532,12 +573,12 @@ from successive locations of an array whose first element is designated
|
|
| 532 |
by `s`.[^38] Characters are inserted until either of the following
|
| 533 |
occurs:
|
| 534 |
|
| 535 |
- `n` characters are inserted;
|
| 536 |
- inserting in the output sequence fails (in which case the function
|
| 537 |
-
calls `setstate(badbit)`, which may throw
|
| 538 |
-
|
| 539 |
|
| 540 |
*Returns:* `*this`.
|
| 541 |
|
| 542 |
``` cpp
|
| 543 |
basic_ostream& flush();
|
|
@@ -545,17 +586,20 @@ basic_ostream& flush();
|
|
| 545 |
|
| 546 |
*Effects:* Behaves as an unformatted output function (as described
|
| 547 |
above). If `rdbuf()` is not a null pointer, constructs a sentry object.
|
| 548 |
If this object returns `true` when converted to a value of type `bool`
|
| 549 |
the function calls `rdbuf()->pubsync()`. If that function returns -1
|
| 550 |
-
calls `setstate(badbit)` (which may throw
|
| 551 |
-
|
| 552 |
-
|
| 553 |
|
| 554 |
*Returns:* `*this`.
|
| 555 |
|
| 556 |
-
#### Standard
|
|
|
|
|
|
|
|
|
|
| 557 |
|
| 558 |
``` cpp
|
| 559 |
template<class charT, class traits>
|
| 560 |
basic_ostream<charT, traits>& endl(basic_ostream<charT, traits>& os);
|
| 561 |
```
|
|
@@ -581,19 +625,60 @@ template <class charT, class traits>
|
|
| 581 |
|
| 582 |
*Effects:* Calls `os.flush()`.
|
| 583 |
|
| 584 |
*Returns:* `os`.
|
| 585 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 586 |
#### Rvalue stream insertion <a id="ostream.rvalue">[[ostream.rvalue]]</a>
|
| 587 |
|
| 588 |
``` cpp
|
| 589 |
-
template
|
| 590 |
-
|
| 591 |
```
|
| 592 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 593 |
*Effects:* As if by: `os << x;`
|
| 594 |
|
| 595 |
-
*Returns:* `os`.
|
| 596 |
-
|
| 597 |
-
*Remarks:* This function shall not participate in overload resolution
|
| 598 |
-
unless the expression `os << x` is well-formed.
|
| 599 |
|
|
|
|
| 9 |
``` cpp
|
| 10 |
namespace std {
|
| 11 |
template<class charT, class traits = char_traits<charT>>
|
| 12 |
class basic_ostream : virtual public basic_ios<charT, traits> {
|
| 13 |
public:
|
| 14 |
+
// types (inherited from basic_ios[ios])
|
| 15 |
using char_type = charT;
|
| 16 |
using int_type = typename traits::int_type;
|
| 17 |
using pos_type = typename traits::pos_type;
|
| 18 |
using off_type = typename traits::off_type;
|
| 19 |
using traits_type = traits;
|
| 20 |
|
| 21 |
// [ostream.cons], constructor/destructor
|
| 22 |
explicit basic_ostream(basic_streambuf<char_type, traits>* sb);
|
| 23 |
virtual ~basic_ostream();
|
| 24 |
|
| 25 |
+
// [ostream.sentry], prefix/suffix
|
| 26 |
class sentry;
|
| 27 |
|
| 28 |
// [ostream.formatted], formatted output
|
| 29 |
basic_ostream<charT, traits>&
|
| 30 |
operator<<(basic_ostream<charT, traits>& (*pf)(basic_ostream<charT, traits>&));
|
|
|
|
| 61 |
basic_ostream<charT, traits>& seekp(pos_type);
|
| 62 |
basic_ostream<charT, traits>& seekp(off_type, ios_base::seekdir);
|
| 63 |
|
| 64 |
protected:
|
| 65 |
// [ostream.cons], copy/move constructor
|
| 66 |
+
basic_ostream(const basic_ostream&) = delete;
|
| 67 |
basic_ostream(basic_ostream&& rhs);
|
| 68 |
|
| 69 |
// [ostream.assign], assign and swap
|
| 70 |
+
basic_ostream& operator=(const basic_ostream&) = delete;
|
| 71 |
basic_ostream& operator=(basic_ostream&& rhs);
|
| 72 |
void swap(basic_ostream& rhs);
|
| 73 |
};
|
| 74 |
|
| 75 |
// [ostream.inserters.character], character inserters
|
|
|
|
| 83 |
template<class traits>
|
| 84 |
basic_ostream<char, traits>& operator<<(basic_ostream<char, traits>&, signed char);
|
| 85 |
template<class traits>
|
| 86 |
basic_ostream<char, traits>& operator<<(basic_ostream<char, traits>&, unsigned char);
|
| 87 |
|
| 88 |
+
template<class traits>
|
| 89 |
+
basic_ostream<char, traits>& operator<<(basic_ostream<char, traits>&, wchar_t) = delete;
|
| 90 |
+
template<class traits>
|
| 91 |
+
basic_ostream<char, traits>& operator<<(basic_ostream<char, traits>&, char8_t) = delete;
|
| 92 |
+
template<class traits>
|
| 93 |
+
basic_ostream<char, traits>& operator<<(basic_ostream<char, traits>&, char16_t) = delete;
|
| 94 |
+
template<class traits>
|
| 95 |
+
basic_ostream<char, traits>& operator<<(basic_ostream<char, traits>&, char32_t) = delete;
|
| 96 |
+
template<class traits>
|
| 97 |
+
basic_ostream<wchar_t, traits>&
|
| 98 |
+
operator<<(basic_ostream<wchar_t, traits>&, char8_t) = delete;
|
| 99 |
+
template<class traits>
|
| 100 |
+
basic_ostream<wchar_t, traits>&
|
| 101 |
+
operator<<(basic_ostream<wchar_t, traits>&, char16_t) = delete;
|
| 102 |
+
template<class traits>
|
| 103 |
+
basic_ostream<wchar_t, traits>&
|
| 104 |
+
operator<<(basic_ostream<wchar_t, traits>&, char32_t) = delete;
|
| 105 |
+
|
| 106 |
template<class charT, class traits>
|
| 107 |
basic_ostream<charT, traits>& operator<<(basic_ostream<charT, traits>&, const charT*);
|
| 108 |
template<class charT, class traits>
|
| 109 |
basic_ostream<charT, traits>& operator<<(basic_ostream<charT, traits>&, const char*);
|
| 110 |
template<class traits>
|
|
|
|
| 112 |
|
| 113 |
template<class traits>
|
| 114 |
basic_ostream<char, traits>& operator<<(basic_ostream<char, traits>&, const signed char*);
|
| 115 |
template<class traits>
|
| 116 |
basic_ostream<char, traits>& operator<<(basic_ostream<char, traits>&, const unsigned char*);
|
| 117 |
+
|
| 118 |
+
template<class traits>
|
| 119 |
+
basic_ostream<char, traits>&
|
| 120 |
+
operator<<(basic_ostream<char, traits>&, const wchar_t*) = delete;
|
| 121 |
+
template<class traits>
|
| 122 |
+
basic_ostream<char, traits>&
|
| 123 |
+
operator<<(basic_ostream<char, traits>&, const char8_t*) = delete;
|
| 124 |
+
template<class traits>
|
| 125 |
+
basic_ostream<char, traits>&
|
| 126 |
+
operator<<(basic_ostream<char, traits>&, const char16_t*) = delete;
|
| 127 |
+
template<class traits>
|
| 128 |
+
basic_ostream<char, traits>&
|
| 129 |
+
operator<<(basic_ostream<char, traits>&, const char32_t*) = delete;
|
| 130 |
+
template<class traits>
|
| 131 |
+
basic_ostream<wchar_t, traits>&
|
| 132 |
+
operator<<(basic_ostream<wchar_t, traits>&, const char8_t*) = delete;
|
| 133 |
+
template<class traits>
|
| 134 |
+
basic_ostream<wchar_t, traits>&
|
| 135 |
+
operator<<(basic_ostream<wchar_t, traits>&, const char16_t*) = delete;
|
| 136 |
+
template<class traits>
|
| 137 |
+
basic_ostream<wchar_t, traits>&
|
| 138 |
+
operator<<(basic_ostream<wchar_t, traits>&, const char32_t*) = delete;
|
| 139 |
}
|
| 140 |
```
|
| 141 |
|
| 142 |
The class template `basic_ostream` defines a number of member function
|
| 143 |
signatures that assist in formatting and writing output to output
|
|
|
|
| 150 |
`rdbuf()->sputc(int_type)`. They may use other public members of
|
| 151 |
`basic_ostream` except that they shall not invoke any virtual members of
|
| 152 |
`rdbuf()` except `overflow()`, `xsputn()`, and `sync()`.
|
| 153 |
|
| 154 |
If one of these called functions throws an exception, then unless
|
| 155 |
+
explicitly noted otherwise the output function sets `badbit` in the
|
| 156 |
+
error state. If `badbit` is set in `exceptions()`, the output function
|
| 157 |
+
rethrows the exception without completing its actions, otherwise it does
|
| 158 |
+
not throw anything and proceeds as if the called function had returned a
|
| 159 |
+
failure indication.
|
| 160 |
|
| 161 |
+
[*Note 1*: The deleted overloads of `operator<<` prevent formatting
|
| 162 |
+
characters as integers and strings as pointers. — *end note*]
|
| 163 |
+
|
| 164 |
+
##### Constructors <a id="ostream.cons">[[ostream.cons]]</a>
|
| 165 |
|
| 166 |
``` cpp
|
| 167 |
explicit basic_ostream(basic_streambuf<charT, traits>* sb);
|
| 168 |
```
|
| 169 |
|
| 170 |
+
*Effects:* Initializes the base class subobject with
|
| 171 |
+
`basic_ios<charT, traits>::init(sb)` [[basic.ios.cons]].
|
|
|
|
| 172 |
|
| 173 |
+
*Ensures:* `rdbuf() == sb`.
|
| 174 |
|
| 175 |
``` cpp
|
| 176 |
basic_ostream(basic_ostream&& rhs);
|
| 177 |
```
|
| 178 |
|
|
|
|
| 182 |
|
| 183 |
``` cpp
|
| 184 |
virtual ~basic_ostream();
|
| 185 |
```
|
| 186 |
|
|
|
|
|
|
|
| 187 |
*Remarks:* Does not perform any operations on `rdbuf()`.
|
| 188 |
|
| 189 |
+
##### Assignment and swap <a id="ostream.assign">[[ostream.assign]]</a>
|
| 190 |
|
| 191 |
``` cpp
|
| 192 |
basic_ostream& operator=(basic_ostream&& rhs);
|
| 193 |
```
|
| 194 |
|
| 195 |
+
*Effects:* Equivalent to: `swap(rhs)`.
|
| 196 |
|
| 197 |
*Returns:* `*this`.
|
| 198 |
|
| 199 |
``` cpp
|
| 200 |
void swap(basic_ostream& rhs);
|
| 201 |
```
|
| 202 |
|
| 203 |
*Effects:* Calls `basic_ios<charT, traits>::swap(rhs)`.
|
| 204 |
|
| 205 |
+
##### Class `basic_ostream::sentry` <a id="ostream.sentry">[[ostream.sentry]]</a>
|
| 206 |
|
| 207 |
``` cpp
|
| 208 |
namespace std {
|
| 209 |
template<class charT, class traits = char_traits<charT>>
|
| 210 |
class basic_ostream<charT, traits>::sentry {
|
|
|
|
| 231 |
If `os.tie()` is not a null pointer, calls `os.tie()->flush()`.[^31]
|
| 232 |
|
| 233 |
If, after any preparation is completed, `os.good()` is `true`,
|
| 234 |
`ok_ == true` otherwise, `ok_ == false`. During preparation, the
|
| 235 |
constructor may call `setstate(failbit)` (which may throw
|
| 236 |
+
`ios_base::failure` [[iostate.flags]]).[^32]
|
| 237 |
|
| 238 |
``` cpp
|
| 239 |
~sentry();
|
| 240 |
```
|
| 241 |
|
|
|
|
| 248 |
explicit operator bool() const;
|
| 249 |
```
|
| 250 |
|
| 251 |
*Effects:* Returns `ok_`.
|
| 252 |
|
| 253 |
+
##### Seek members <a id="ostream.seeks">[[ostream.seeks]]</a>
|
| 254 |
|
| 255 |
Each seek member function begins execution by constructing an object of
|
| 256 |
class `sentry`. It returns by destroying the `sentry` object.
|
| 257 |
|
| 258 |
``` cpp
|
|
|
|
| 291 |
Each formatted output function begins execution by constructing an
|
| 292 |
object of class `sentry`. If this object returns `true` when converted
|
| 293 |
to a value of type `bool`, the function endeavors to generate the
|
| 294 |
requested output. If the generation fails, then the formatted output
|
| 295 |
function does `setstate(ios_base::failbit)`, which might throw an
|
| 296 |
+
exception. If an exception is thrown during output, then
|
| 297 |
+
`ios_base::badbit` is turned on[^33] in `*this`’s error state. If
|
| 298 |
`(exceptions()&badbit) != 0` then the exception is rethrown. Whether or
|
| 299 |
not an exception is thrown, the `sentry` object is destroyed before
|
| 300 |
leaving the formatted output function. If no exception is thrown, the
|
| 301 |
result of the formatted output function is `*this`.
|
| 302 |
|
|
|
|
| 437 |
|
| 438 |
``` cpp
|
| 439 |
basic_ostream<charT, traits>& operator<<(basic_streambuf<charT, traits>* sb);
|
| 440 |
```
|
| 441 |
|
| 442 |
+
*Effects:* Behaves as an unformatted output
|
| 443 |
+
function [[ostream.unformatted]]. After the sentry object is
|
| 444 |
+
constructed, if `sb` is null calls `setstate(badbit)` (which may throw
|
| 445 |
`ios_base::failure`).
|
| 446 |
|
| 447 |
Gets characters from `sb` and inserts them in `*this`. Characters are
|
| 448 |
read from `sb` and inserted until any of the following occurs:
|
| 449 |
|
|
|
|
| 451 |
- inserting in the output sequence fails (in which case the character to
|
| 452 |
be inserted is not extracted);
|
| 453 |
- an exception occurs while getting a character from `sb`.
|
| 454 |
|
| 455 |
If the function inserts no characters, it calls `setstate(failbit)`
|
| 456 |
+
(which may throw `ios_base::failure` [[iostate.flags]]). If an exception
|
| 457 |
+
was thrown while extracting a character, the function sets `failbit` in
|
| 458 |
+
the error state, and if `failbit` is set in `exceptions()` the caught
|
| 459 |
+
exception is rethrown.
|
| 460 |
|
| 461 |
*Returns:* `*this`.
|
| 462 |
|
| 463 |
``` cpp
|
| 464 |
basic_ostream<charT, traits>& operator<<(nullptr_t);
|
|
|
|
| 468 |
|
| 469 |
``` cpp
|
| 470 |
return *this << s;
|
| 471 |
```
|
| 472 |
|
| 473 |
+
where `s` is an *implementation-defined* NTCTS [[defns.ntcts]].
|
| 474 |
|
| 475 |
##### Character inserter function templates <a id="ostream.inserters.character">[[ostream.inserters.character]]</a>
|
| 476 |
|
| 477 |
``` cpp
|
| 478 |
template<class charT, class traits>
|
|
|
|
| 488 |
template<class traits>
|
| 489 |
basic_ostream<char, traits>& operator<<(basic_ostream<char, traits>& out, unsigned char c);
|
| 490 |
```
|
| 491 |
|
| 492 |
*Effects:* Behaves as a formatted output
|
| 493 |
+
function [[ostream.formatted.reqmts]] of `out`. Constructs a character
|
| 494 |
+
sequence `seq`. If `c` has type `char` and the character type of the
|
| 495 |
+
stream is not `char`, then `seq` consists of `out.widen(c)`; otherwise
|
| 496 |
+
`seq` consists of `c`. Determines padding for `seq` as described
|
| 497 |
+
in [[ostream.formatted.reqmts]]. Inserts `seq` into `out`. Calls
|
| 498 |
+
`os.width(0)`.
|
| 499 |
|
| 500 |
*Returns:* `out`.
|
| 501 |
|
| 502 |
``` cpp
|
| 503 |
template<class charT, class traits>
|
|
|
|
| 511 |
template<class traits>
|
| 512 |
basic_ostream<char, traits>& operator<<(basic_ostream<char, traits>& out,
|
| 513 |
const unsigned char* s);
|
| 514 |
```
|
| 515 |
|
| 516 |
+
*Preconditions:* `s` is not a null pointer.
|
| 517 |
|
| 518 |
*Effects:* Behaves like a formatted inserter (as described
|
| 519 |
in [[ostream.formatted.reqmts]]) of `out`. Creates a character sequence
|
| 520 |
`seq` of `n` characters starting at `s`, each widened using
|
| 521 |
+
`out.widen()` [[basic.ios.members]], where `n` is the number that would
|
| 522 |
+
be computed as if by:
|
| 523 |
|
| 524 |
- `traits::length(s)` for the overload where the first argument is of
|
| 525 |
type `basic_ostream<charT, traits>&` and the second is of type
|
| 526 |
`const charT*`, and also for the overload where the first argument is
|
| 527 |
of type `basic_ostream<char, traits>&` and the second is of type
|
|
|
|
| 542 |
|
| 543 |
Each unformatted output function begins execution by constructing an
|
| 544 |
object of class `sentry`. If this object returns `true`, while
|
| 545 |
converting to a value of type `bool`, the function endeavors to generate
|
| 546 |
the requested output. If an exception is thrown during output, then
|
| 547 |
+
`ios_base::badbit` is turned on[^36] in `*this`’s error state. If
|
| 548 |
`(exceptions() & badbit) != 0` then the exception is rethrown. In any
|
| 549 |
case, the unformatted output function ends by destroying the sentry
|
| 550 |
object, then, if no exception was thrown, returning the value specified
|
| 551 |
for the unformatted output function.
|
| 552 |
|
|
|
|
| 556 |
|
| 557 |
*Effects:* Behaves as an unformatted output function (as described
|
| 558 |
above). After constructing a sentry object, inserts the character `c`,
|
| 559 |
if possible.[^37]
|
| 560 |
|
| 561 |
+
Otherwise, calls `setstate(badbit)` (which may throw `ios_base::failure`
|
| 562 |
+
[[iostate.flags]]).
|
| 563 |
|
| 564 |
*Returns:* `*this`.
|
| 565 |
|
| 566 |
``` cpp
|
| 567 |
basic_ostream& write(const char_type* s, streamsize n);
|
|
|
|
| 573 |
by `s`.[^38] Characters are inserted until either of the following
|
| 574 |
occurs:
|
| 575 |
|
| 576 |
- `n` characters are inserted;
|
| 577 |
- inserting in the output sequence fails (in which case the function
|
| 578 |
+
calls `setstate(badbit)`, which may throw `ios_base::failure`
|
| 579 |
+
[[iostate.flags]]).
|
| 580 |
|
| 581 |
*Returns:* `*this`.
|
| 582 |
|
| 583 |
``` cpp
|
| 584 |
basic_ostream& flush();
|
|
|
|
| 586 |
|
| 587 |
*Effects:* Behaves as an unformatted output function (as described
|
| 588 |
above). If `rdbuf()` is not a null pointer, constructs a sentry object.
|
| 589 |
If this object returns `true` when converted to a value of type `bool`
|
| 590 |
the function calls `rdbuf()->pubsync()`. If that function returns -1
|
| 591 |
+
calls `setstate(badbit)` (which may throw `ios_base::failure`
|
| 592 |
+
[[iostate.flags]]). Otherwise, if the sentry object returns `false`,
|
| 593 |
+
does nothing.
|
| 594 |
|
| 595 |
*Returns:* `*this`.
|
| 596 |
|
| 597 |
+
#### Standard manipulators <a id="ostream.manip">[[ostream.manip]]</a>
|
| 598 |
+
|
| 599 |
+
Each instantiation of any of the function templates specified in this
|
| 600 |
+
subclause is a designated addressable function [[namespace.std]].
|
| 601 |
|
| 602 |
``` cpp
|
| 603 |
template<class charT, class traits>
|
| 604 |
basic_ostream<charT, traits>& endl(basic_ostream<charT, traits>& os);
|
| 605 |
```
|
|
|
|
| 625 |
|
| 626 |
*Effects:* Calls `os.flush()`.
|
| 627 |
|
| 628 |
*Returns:* `os`.
|
| 629 |
|
| 630 |
+
``` cpp
|
| 631 |
+
template<class charT, class traits>
|
| 632 |
+
basic_ostream<charT, traits>& emit_on_flush(basic_ostream<charT, traits>& os);
|
| 633 |
+
```
|
| 634 |
+
|
| 635 |
+
*Effects:* If `os.rdbuf()` is a
|
| 636 |
+
`basic_syncbuf<charT, traits, Allocator>*`, called `buf` for the purpose
|
| 637 |
+
of exposition, calls `buf->set_emit_on_sync(true)`. Otherwise this
|
| 638 |
+
manipulator has no effect.
|
| 639 |
+
|
| 640 |
+
[*Note 1*: To work around the issue that the `Allocator` template
|
| 641 |
+
argument cannot be deduced, implementations can introduce an
|
| 642 |
+
intermediate base class to `basic_syncbuf` that manages its
|
| 643 |
+
`emit_on_sync` flag. — *end note*]
|
| 644 |
+
|
| 645 |
+
*Returns:* `os`.
|
| 646 |
+
|
| 647 |
+
``` cpp
|
| 648 |
+
template<class charT, class traits>
|
| 649 |
+
basic_ostream<charT, traits>& noemit_on_flush(basic_ostream<charT, traits>& os);
|
| 650 |
+
```
|
| 651 |
+
|
| 652 |
+
*Effects:* If `os.rdbuf()` is a
|
| 653 |
+
`basic_syncbuf<charT, traits, Allocator>*`, called `buf` for the purpose
|
| 654 |
+
of exposition, calls `buf->set_emit_on_sync(false)`. Otherwise this
|
| 655 |
+
manipulator has no effect.
|
| 656 |
+
|
| 657 |
+
*Returns:* `os`.
|
| 658 |
+
|
| 659 |
+
``` cpp
|
| 660 |
+
template<class charT, class traits>
|
| 661 |
+
basic_ostream<charT, traits>& flush_emit(basic_ostream<charT, traits>& os);
|
| 662 |
+
```
|
| 663 |
+
|
| 664 |
+
*Effects:* Calls `os.flush()`. Then, if `os.rdbuf()` is a
|
| 665 |
+
`basic_syncbuf<charT, traits, Allocator>*`, called `buf` for the purpose
|
| 666 |
+
of exposition, calls `buf->emit()`.
|
| 667 |
+
|
| 668 |
+
*Returns:* `os`.
|
| 669 |
+
|
| 670 |
#### Rvalue stream insertion <a id="ostream.rvalue">[[ostream.rvalue]]</a>
|
| 671 |
|
| 672 |
``` cpp
|
| 673 |
+
template<class Ostream, class T>
|
| 674 |
+
Ostream&& operator<<(Ostream&& os, const T& x);
|
| 675 |
```
|
| 676 |
|
| 677 |
+
*Constraints:* The expression `os << x` is well-formed when treated as
|
| 678 |
+
an unevaluated operand and `Ostream` is publicly and unambiguously
|
| 679 |
+
derived from `ios_base`.
|
| 680 |
+
|
| 681 |
*Effects:* As if by: `os << x;`
|
| 682 |
|
| 683 |
+
*Returns:* `std::move(os)`.
|
|
|
|
|
|
|
|
|
|
| 684 |
|