- tmp/tmp1uls7k6g/{from.md → to.md} +99 -106
tmp/tmp1uls7k6g/{from.md → to.md}
RENAMED
|
@@ -9,22 +9,22 @@ extracts from stream rvalues.
|
|
| 9 |
``` cpp
|
| 10 |
namespace std {
|
| 11 |
template<class charT, class traits = char_traits<charT>>
|
| 12 |
class basic_istream : 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 |
// [istream.cons], constructor/destructor
|
| 22 |
explicit basic_istream(basic_streambuf<charT, traits>* sb);
|
| 23 |
virtual ~basic_istream();
|
| 24 |
|
| 25 |
-
// [istream
|
| 26 |
class sentry;
|
| 27 |
|
| 28 |
// [istream.formatted], formatted input
|
| 29 |
basic_istream<charT, traits>&
|
| 30 |
operator>>(basic_istream<charT, traits>& (*pf)(basic_istream<charT, traits>&));
|
|
@@ -74,15 +74,15 @@ namespace std {
|
|
| 74 |
basic_istream<charT, traits>& seekg(pos_type);
|
| 75 |
basic_istream<charT, traits>& seekg(off_type, ios_base::seekdir);
|
| 76 |
|
| 77 |
protected:
|
| 78 |
// [istream.cons], copy/move constructor
|
| 79 |
-
basic_istream(const basic_istream&
|
| 80 |
basic_istream(basic_istream&& rhs);
|
| 81 |
|
| 82 |
// [istream.assign], assign and swap
|
| 83 |
-
basic_istream& operator=(const basic_istream&
|
| 84 |
basic_istream& operator=(basic_istream&& rhs);
|
| 85 |
void swap(basic_istream& rhs);
|
| 86 |
};
|
| 87 |
|
| 88 |
// [istream.extractors], character extraction templates
|
|
@@ -91,16 +91,16 @@ namespace std {
|
|
| 91 |
template<class traits>
|
| 92 |
basic_istream<char, traits>& operator>>(basic_istream<char, traits>&, unsigned char&);
|
| 93 |
template<class traits>
|
| 94 |
basic_istream<char, traits>& operator>>(basic_istream<char, traits>&, signed char&);
|
| 95 |
|
| 96 |
-
template<class charT, class traits>
|
| 97 |
-
basic_istream<charT, traits>& operator>>(basic_istream<charT, traits>&, charT
|
| 98 |
-
template<class traits>
|
| 99 |
-
basic_istream<char, traits>& operator>>(basic_istream<char, traits>&, unsigned char
|
| 100 |
-
template<class traits>
|
| 101 |
-
basic_istream<char, traits>& operator>>(basic_istream<char, traits>&, signed char
|
| 102 |
}
|
| 103 |
```
|
| 104 |
|
| 105 |
The class template `basic_istream` defines a number of member function
|
| 106 |
signatures that assist in reading and interpreting input from sequences
|
|
@@ -113,72 +113,67 @@ obtain (or *extract*) input *characters* by calling `rdbuf()->sbumpc()`
|
|
| 113 |
or `rdbuf()->sgetc()`. They may use other public members of `istream`.
|
| 114 |
|
| 115 |
If `rdbuf()->sbumpc()` or `rdbuf()->sgetc()` returns `traits::eof()`,
|
| 116 |
then the input function, except as explicitly noted otherwise, completes
|
| 117 |
its actions and does `setstate(eofbit)`, which may throw
|
| 118 |
-
`ios_base::failure`
|
| 119 |
|
| 120 |
If one of these called functions throws an exception, then unless
|
| 121 |
-
explicitly noted otherwise, the input function sets `badbit` in
|
| 122 |
-
state. If `badbit` is
|
| 123 |
-
the exception without completing its actions, otherwise it does
|
| 124 |
-
throw anything and proceeds as if the called function had returned a
|
| 125 |
failure indication.
|
| 126 |
|
| 127 |
-
#####
|
| 128 |
|
| 129 |
``` cpp
|
| 130 |
explicit basic_istream(basic_streambuf<charT, traits>* sb);
|
| 131 |
```
|
| 132 |
|
| 133 |
-
*Effects:*
|
| 134 |
-
|
| 135 |
-
`basic_ios::init(sb)` ([[basic.ios.cons]]).
|
| 136 |
|
| 137 |
-
*
|
| 138 |
|
| 139 |
``` cpp
|
| 140 |
basic_istream(basic_istream&& rhs);
|
| 141 |
```
|
| 142 |
|
| 143 |
-
*Effects:*
|
| 144 |
-
|
| 145 |
-
|
| 146 |
-
base class, and setting the `gcount()` for `rhs` to 0.
|
| 147 |
|
| 148 |
``` cpp
|
| 149 |
virtual ~basic_istream();
|
| 150 |
```
|
| 151 |
|
| 152 |
-
*Effects:* Destroys an object of class `basic_istream`.
|
| 153 |
-
|
| 154 |
*Remarks:* Does not perform any operations of `rdbuf()`.
|
| 155 |
|
| 156 |
-
#####
|
| 157 |
|
| 158 |
``` cpp
|
| 159 |
basic_istream& operator=(basic_istream&& rhs);
|
| 160 |
```
|
| 161 |
|
| 162 |
-
*Effects:*
|
| 163 |
|
| 164 |
*Returns:* `*this`.
|
| 165 |
|
| 166 |
``` cpp
|
| 167 |
void swap(basic_istream& rhs);
|
| 168 |
```
|
| 169 |
|
| 170 |
*Effects:* Calls `basic_ios<charT, traits>::swap(rhs)`. Exchanges the
|
| 171 |
values returned by `gcount()` and `rhs.gcount()`.
|
| 172 |
|
| 173 |
-
##### Class `basic_istream::sentry` <a id="istream
|
| 174 |
|
| 175 |
``` cpp
|
| 176 |
namespace std {
|
| 177 |
template<class charT, class traits = char_traits<charT>>
|
| 178 |
class basic_istream<charT, traits>::sentry {
|
| 179 |
-
using traits_type = traits;
|
| 180 |
bool ok_; // exposition only
|
| 181 |
public:
|
| 182 |
explicit sentry(basic_istream<charT, traits>& is, bool noskipws = false);
|
| 183 |
~sentry();
|
| 184 |
explicit operator bool() const { return ok_; }
|
|
@@ -229,11 +224,11 @@ if (ctype.is(ctype.space, c) != 0)
|
|
| 229 |
```
|
| 230 |
|
| 231 |
If, after any preparation is completed, `is.good()` is `true`,
|
| 232 |
`ok_ != false` otherwise, `ok_ == false`. During preparation, the
|
| 233 |
constructor may call `setstate(failbit)` (which may throw
|
| 234 |
-
`ios_base::failure`
|
| 235 |
|
| 236 |
``` cpp
|
| 237 |
~sentry();
|
| 238 |
```
|
| 239 |
|
|
@@ -241,23 +236,23 @@ constructor may call `setstate(failbit)` (which may throw
|
|
| 241 |
|
| 242 |
``` cpp
|
| 243 |
explicit operator bool() const;
|
| 244 |
```
|
| 245 |
|
| 246 |
-
*
|
| 247 |
|
| 248 |
#### Formatted input functions <a id="istream.formatted">[[istream.formatted]]</a>
|
| 249 |
|
| 250 |
##### Common requirements <a id="istream.formatted.reqmts">[[istream.formatted.reqmts]]</a>
|
| 251 |
|
| 252 |
Each formatted input function begins execution by constructing an object
|
| 253 |
of class `sentry` with the `noskipws` (second) argument `false`. If the
|
| 254 |
`sentry` object returns `true`, when converted to a value of type
|
| 255 |
`bool`, the function endeavors to obtain the requested input. If an
|
| 256 |
-
exception is thrown during input then `
|
| 257 |
-
`*this`’s error state. If `(exceptions()&badbit) != 0` then
|
| 258 |
-
exception is rethrown. In any case, the formatted input function
|
| 259 |
destroys the `sentry` object. If no exception has been thrown, it
|
| 260 |
returns `*this`.
|
| 261 |
|
| 262 |
##### Arithmetic extractors <a id="istream.formatted.arithmetic">[[istream.formatted.arithmetic]]</a>
|
| 263 |
|
|
@@ -274,11 +269,11 @@ operator>>(long double& val);
|
|
| 274 |
operator>>(bool& val);
|
| 275 |
operator>>(void*& val);
|
| 276 |
```
|
| 277 |
|
| 278 |
As in the case of the inserters, these extractors depend on the locale’s
|
| 279 |
-
`num_get<>`
|
| 280 |
stream data. These extractors behave as formatted input functions (as
|
| 281 |
described in [[istream.formatted.reqmts]]). After a sentry object is
|
| 282 |
constructed, the conversion occurs as if performed by the following code
|
| 283 |
fragment:
|
| 284 |
|
|
@@ -378,26 +373,23 @@ formatted input function (as described
|
|
| 378 |
in [[istream.formatted.reqmts]]).
|
| 379 |
|
| 380 |
*Returns:* `*this`.
|
| 381 |
|
| 382 |
``` cpp
|
| 383 |
-
template<class charT, class traits>
|
| 384 |
-
basic_istream<charT, traits>& operator>>(basic_istream<charT, traits>& in, charT
|
| 385 |
-
template<class traits>
|
| 386 |
-
basic_istream<char, traits>& operator>>(basic_istream<char, traits>& in, unsigned char
|
| 387 |
-
template<class traits>
|
| 388 |
-
basic_istream<char, traits>& operator>>(basic_istream<char, traits>& in, signed char
|
| 389 |
```
|
| 390 |
|
| 391 |
*Effects:* Behaves like a formatted input member (as described
|
| 392 |
in [[istream.formatted.reqmts]]) of `in`. After a `sentry` object is
|
| 393 |
-
constructed, `operator>>` extracts characters and stores them into
|
| 394 |
-
|
| 395 |
-
`
|
| 396 |
-
is the number of elements of the largest array of `char_type` that can
|
| 397 |
-
store a terminating `charT()`. `n` is the maximum number of characters
|
| 398 |
-
stored.
|
| 399 |
|
| 400 |
Characters are extracted and stored until any of the following occurs:
|
| 401 |
|
| 402 |
- `n-1` characters are stored;
|
| 403 |
- end of file occurs on the input sequence;
|
|
@@ -407,11 +399,11 @@ Characters are extracted and stored until any of the following occurs:
|
|
| 407 |
`operator>>` then stores a null byte (`charT()`) in the next position,
|
| 408 |
which may be the first position if no characters were extracted.
|
| 409 |
`operator>>` then calls `width(0)`.
|
| 410 |
|
| 411 |
If the function extracted no characters, it calls `setstate(failbit)`,
|
| 412 |
-
which may throw `ios_base::failure`
|
| 413 |
|
| 414 |
*Returns:* `in`.
|
| 415 |
|
| 416 |
``` cpp
|
| 417 |
template<class charT, class traits>
|
|
@@ -431,28 +423,28 @@ stored in `c`. Otherwise, the function calls `in.setstate(failbit)`.
|
|
| 431 |
|
| 432 |
``` cpp
|
| 433 |
basic_istream<charT, traits>& operator>>(basic_streambuf<charT, traits>* sb);
|
| 434 |
```
|
| 435 |
|
| 436 |
-
*Effects:* Behaves as an unformatted input
|
| 437 |
-
|
| 438 |
-
which may throw `ios_base::failure`
|
| 439 |
-
object is constructed, extracts
|
| 440 |
-
|
| 441 |
-
inserted until any of
|
|
|
|
| 442 |
|
| 443 |
- end-of-file occurs on the input sequence;
|
| 444 |
- inserting in the output sequence fails (in which case the character to
|
| 445 |
be inserted is not extracted);
|
| 446 |
- an exception occurs (in which case the exception is caught).
|
| 447 |
|
| 448 |
If the function inserts no characters, it calls `setstate(failbit)`,
|
| 449 |
-
which may throw `ios_base::failure`
|
| 450 |
-
|
| 451 |
-
characters from `*this` and `failbit` is
|
| 452 |
-
|
| 453 |
-
rethrown.
|
| 454 |
|
| 455 |
*Returns:* `*this`.
|
| 456 |
|
| 457 |
#### Unformatted input functions <a id="istream.unformatted">[[istream.unformatted]]</a>
|
| 458 |
|
|
@@ -465,14 +457,14 @@ an exception or if the sentry object returns `false`, when converted to
|
|
| 465 |
a value of type `bool`, the function returns without attempting to
|
| 466 |
obtain any input. In either case the number of extracted characters is
|
| 467 |
set to 0; unformatted input functions taking a character array of
|
| 468 |
nonzero size as an argument shall also store a null character (using
|
| 469 |
`charT()`) in the first location of the array. If an exception is thrown
|
| 470 |
-
during input then `
|
| 471 |
-
state. (Exceptions thrown from `basic_ios<>::clear()` are not
|
| 472 |
-
rethrown.) If `(exceptions()&badbit) != 0` then the exception
|
| 473 |
-
rethrown. It also counts the number of characters extracted. If no
|
| 474 |
exception has been thrown it ends by storing the count in a member
|
| 475 |
object and returning the value specified. In any event the `sentry`
|
| 476 |
object is destroyed before leaving the unformatted input function.
|
| 477 |
|
| 478 |
``` cpp
|
|
@@ -490,23 +482,23 @@ int_type get();
|
|
| 490 |
```
|
| 491 |
|
| 492 |
*Effects:* Behaves as an unformatted input function (as described
|
| 493 |
above). After constructing a sentry object, extracts a character `c`, if
|
| 494 |
one is available. Otherwise, the function calls `setstate(failbit)`,
|
| 495 |
-
which may throw `ios_base::failure`
|
| 496 |
|
| 497 |
*Returns:* `c` if available, otherwise `traits::eof()`.
|
| 498 |
|
| 499 |
``` cpp
|
| 500 |
basic_istream<charT, traits>& get(char_type& c);
|
| 501 |
```
|
| 502 |
|
| 503 |
*Effects:* Behaves as an unformatted input function (as described
|
| 504 |
above). After constructing a sentry object, extracts a character, if one
|
| 505 |
is available, and assigns it to `c`.[^24] Otherwise, the function calls
|
| 506 |
-
`setstate(failbit)` (which may throw
|
| 507 |
-
|
| 508 |
|
| 509 |
*Returns:* `*this`.
|
| 510 |
|
| 511 |
``` cpp
|
| 512 |
basic_istream<charT, traits>& get(char_type* s, streamsize n, char_type delim);
|
|
@@ -523,13 +515,13 @@ the following occurs:
|
|
| 523 |
calls `setstate(eofbit)`);
|
| 524 |
- `traits::eq(c, delim)` for the next available input character `c` (in
|
| 525 |
which case `c` is not extracted).
|
| 526 |
|
| 527 |
If the function stores no characters, it calls `setstate(failbit)`
|
| 528 |
-
(which may throw `ios_base::failure`
|
| 529 |
-
|
| 530 |
-
|
| 531 |
|
| 532 |
*Returns:* `*this`.
|
| 533 |
|
| 534 |
``` cpp
|
| 535 |
basic_istream<charT, traits>& get(char_type* s, streamsize n);
|
|
@@ -555,11 +547,11 @@ extracted and inserted until any of the following occurs:
|
|
| 555 |
which case `c` is not extracted);
|
| 556 |
- an exception occurs (in which case, the exception is caught but not
|
| 557 |
rethrown).
|
| 558 |
|
| 559 |
If the function inserts no characters, it calls `setstate(failbit)`,
|
| 560 |
-
which may throw `ios_base::failure`
|
| 561 |
|
| 562 |
*Returns:* `*this`.
|
| 563 |
|
| 564 |
``` cpp
|
| 565 |
basic_istream<charT, traits>& get(basic_streambuf<char_type, traits>& sb);
|
|
@@ -588,11 +580,11 @@ the following occurs:
|
|
| 588 |
the function calls `setstate(failbit)`).
|
| 589 |
|
| 590 |
These conditions are tested in the order shown.[^28]
|
| 591 |
|
| 592 |
If the function extracts no characters, it calls `setstate(failbit)`
|
| 593 |
-
(which may throw `ios_base::failure`
|
| 594 |
|
| 595 |
In any case, if `n` is greater than zero, it then stores a null
|
| 596 |
character (using `charT()`) into the next successive location of the
|
| 597 |
array.
|
| 598 |
|
|
@@ -640,15 +632,15 @@ basic_istream<charT, traits>& ignore(streamsize n = 1, int_type delim = traits::
|
|
| 640 |
*Effects:* Behaves as an unformatted input function (as described
|
| 641 |
above). After constructing a sentry object, extracts characters and
|
| 642 |
discards them. Characters are extracted until any of the following
|
| 643 |
occurs:
|
| 644 |
|
| 645 |
-
- `n != numeric_limits<streamsize>::max()`
|
| 646 |
characters have been extracted so far
|
| 647 |
- end-of-file occurs on the input sequence (in which case the function
|
| 648 |
-
calls `setstate(eofbit)`, which may throw
|
| 649 |
-
|
| 650 |
- `traits::eq_int_type(traits::to_int_type(c), delim)` for the next
|
| 651 |
available input character `c` (in which case `c` is extracted).
|
| 652 |
|
| 653 |
*Remarks:* The last condition will never occur if
|
| 654 |
`traits::eq_int_type(delim, traits::eof())`.
|
|
@@ -678,11 +670,11 @@ array whose first element is designated by `s`.[^30] Characters are
|
|
| 678 |
extracted and stored until either of the following occurs:
|
| 679 |
|
| 680 |
- `n` characters are stored;
|
| 681 |
- end-of-file occurs on the input sequence (in which case the function
|
| 682 |
calls `setstate(failbit | eofbit)`, which may throw
|
| 683 |
-
`ios_base::failure`
|
| 684 |
|
| 685 |
*Returns:* `*this`.
|
| 686 |
|
| 687 |
``` cpp
|
| 688 |
streamsize readsome(char_type* s, streamsize n);
|
|
@@ -692,11 +684,11 @@ streamsize readsome(char_type* s, streamsize n);
|
|
| 692 |
above). After constructing a sentry object, if `!good()` calls
|
| 693 |
`setstate(failbit)` which may throw an exception, and return. Otherwise
|
| 694 |
extracts characters and stores them into successive locations of an
|
| 695 |
array whose first element is designated by `s`. If
|
| 696 |
`rdbuf()->in_avail() == -1`, calls `setstate(eofbit)` (which may throw
|
| 697 |
-
`ios_base::failure`
|
| 698 |
|
| 699 |
- If `rdbuf()->in_avail() == 0`, extracts no characters
|
| 700 |
- If `rdbuf()->in_avail() > 0`, extracts `min(rdbuf()->in_avail(), n))`.
|
| 701 |
|
| 702 |
*Returns:* The number of characters extracted.
|
|
@@ -707,13 +699,13 @@ basic_istream<charT, traits>& putback(char_type c);
|
|
| 707 |
|
| 708 |
*Effects:* Behaves as an unformatted input function (as described
|
| 709 |
above), except that the function first clears `eofbit`. After
|
| 710 |
constructing a sentry object, if `!good()` calls `setstate(failbit)`
|
| 711 |
which may throw an exception, and return. If `rdbuf()` is not null,
|
| 712 |
-
calls `rdbuf->sputbackc()`. If `rdbuf()` is null, or if `sputbackc
|
| 713 |
returns `traits::eof()`, calls `setstate(badbit)` (which may throw
|
| 714 |
-
`ios_base::failure`
|
| 715 |
|
| 716 |
[*Note 1*: This function extracts no characters, so the value returned
|
| 717 |
by the next call to `gcount()` is 0. — *end note*]
|
| 718 |
|
| 719 |
*Returns:* `*this`.
|
|
@@ -724,13 +716,13 @@ basic_istream<charT, traits>& unget();
|
|
| 724 |
|
| 725 |
*Effects:* Behaves as an unformatted input function (as described
|
| 726 |
above), except that the function first clears `eofbit`. After
|
| 727 |
constructing a sentry object, if `!good()` calls `setstate(failbit)`
|
| 728 |
which may throw an exception, and return. If `rdbuf()` is not null,
|
| 729 |
-
calls `rdbuf()->sungetc()`. If `rdbuf()` is null, or if `sungetc
|
| 730 |
returns `traits::eof()`, calls `setstate(badbit)` (which may throw
|
| 731 |
-
`ios_base::failure`
|
| 732 |
|
| 733 |
[*Note 2*: This function extracts no characters, so the value returned
|
| 734 |
by the next call to `gcount()` is 0. — *end note*]
|
| 735 |
|
| 736 |
*Returns:* `*this`.
|
|
@@ -743,11 +735,11 @@ int sync();
|
|
| 743 |
above), except that it does not count the number of characters extracted
|
| 744 |
and does not affect the value returned by subsequent calls to
|
| 745 |
`gcount()`. After constructing a sentry object, if `rdbuf()` is a null
|
| 746 |
pointer, returns `-1`. Otherwise, calls `rdbuf()->pubsync()` and, if
|
| 747 |
that function returns `-1` calls `setstate(badbit)` (which may throw
|
| 748 |
-
`ios_base::failure`
|
| 749 |
returns zero.
|
| 750 |
|
| 751 |
``` cpp
|
| 752 |
pos_type tellg();
|
| 753 |
```
|
|
@@ -791,45 +783,49 @@ function calls `setstate(failbit)` (which may throw
|
|
| 791 |
|
| 792 |
*Returns:* `*this`.
|
| 793 |
|
| 794 |
#### Standard `basic_istream` manipulators <a id="istream.manip">[[istream.manip]]</a>
|
| 795 |
|
|
|
|
|
|
|
|
|
|
| 796 |
``` cpp
|
| 797 |
template<class charT, class traits>
|
| 798 |
basic_istream<charT, traits>& ws(basic_istream<charT, traits>& is);
|
| 799 |
```
|
| 800 |
|
| 801 |
-
*Effects:* Behaves as an unformatted input
|
| 802 |
-
|
| 803 |
-
characters extracted and does not affect the value returned by
|
| 804 |
-
subsequent calls to is.gcount(). After constructing a sentry object
|
| 805 |
extracts characters as long as the next available character `c` is
|
| 806 |
whitespace or until there are no more characters in the sequence.
|
| 807 |
Whitespace characters are distinguished with the same criterion as used
|
| 808 |
-
by `sentry::sentry`
|
| 809 |
characters because there are no more available it sets `eofbit`, but not
|
| 810 |
`failbit`.
|
| 811 |
|
| 812 |
*Returns:* `is`.
|
| 813 |
|
| 814 |
#### Rvalue stream extraction <a id="istream.rvalue">[[istream.rvalue]]</a>
|
| 815 |
|
| 816 |
``` cpp
|
| 817 |
-
template
|
| 818 |
-
|
| 819 |
```
|
| 820 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 821 |
*Effects:* Equivalent to:
|
| 822 |
|
| 823 |
``` cpp
|
| 824 |
is >> std::forward<T>(x);
|
| 825 |
-
return is;
|
| 826 |
```
|
| 827 |
|
| 828 |
-
*Remarks:* This function shall not participate in overload resolution
|
| 829 |
-
unless the expression `is >> std::forward<T>(x)` is well-formed.
|
| 830 |
-
|
| 831 |
#### Class template `basic_iostream` <a id="iostreamclass">[[iostreamclass]]</a>
|
| 832 |
|
| 833 |
``` cpp
|
| 834 |
namespace std {
|
| 835 |
template<class charT, class traits = char_traits<charT>>
|
|
@@ -849,62 +845,59 @@ namespace std {
|
|
| 849 |
// [iostream.dest], destructor
|
| 850 |
virtual ~basic_iostream();
|
| 851 |
|
| 852 |
protected:
|
| 853 |
// [iostream.cons], constructor
|
| 854 |
-
basic_iostream(const basic_iostream&
|
| 855 |
basic_iostream(basic_iostream&& rhs);
|
| 856 |
|
| 857 |
// [iostream.assign], assign and swap
|
| 858 |
-
basic_iostream& operator=(const basic_iostream&
|
| 859 |
basic_iostream& operator=(basic_iostream&& rhs);
|
| 860 |
void swap(basic_iostream& rhs);
|
| 861 |
};
|
| 862 |
}
|
| 863 |
```
|
| 864 |
|
| 865 |
The class template `basic_iostream` inherits a number of functions that
|
| 866 |
allow reading input and writing output to sequences controlled by a
|
| 867 |
stream buffer.
|
| 868 |
|
| 869 |
-
#####
|
| 870 |
|
| 871 |
``` cpp
|
| 872 |
explicit basic_iostream(basic_streambuf<charT, traits>* sb);
|
| 873 |
```
|
| 874 |
|
| 875 |
-
*Effects:*
|
| 876 |
-
|
| 877 |
-
`
|
| 878 |
-
`basic_ostream<charT, traits>(sb)` ([[ostream]]).
|
| 879 |
|
| 880 |
-
*
|
| 881 |
|
| 882 |
``` cpp
|
| 883 |
basic_iostream(basic_iostream&& rhs);
|
| 884 |
```
|
| 885 |
|
| 886 |
*Effects:* Move constructs from the rvalue `rhs` by constructing the
|
| 887 |
`basic_istream` base class with `move(rhs)`.
|
| 888 |
|
| 889 |
-
#####
|
| 890 |
|
| 891 |
``` cpp
|
| 892 |
virtual ~basic_iostream();
|
| 893 |
```
|
| 894 |
|
| 895 |
-
*Effects:* Destroys an object of class `basic_iostream`.
|
| 896 |
-
|
| 897 |
*Remarks:* Does not perform any operations on `rdbuf()`.
|
| 898 |
|
| 899 |
-
#####
|
| 900 |
|
| 901 |
``` cpp
|
| 902 |
basic_iostream& operator=(basic_iostream&& rhs);
|
| 903 |
```
|
| 904 |
|
| 905 |
-
*Effects:*
|
| 906 |
|
| 907 |
``` cpp
|
| 908 |
void swap(basic_iostream& rhs);
|
| 909 |
```
|
| 910 |
|
|
|
|
| 9 |
``` cpp
|
| 10 |
namespace std {
|
| 11 |
template<class charT, class traits = char_traits<charT>>
|
| 12 |
class basic_istream : 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 |
// [istream.cons], constructor/destructor
|
| 22 |
explicit basic_istream(basic_streambuf<charT, traits>* sb);
|
| 23 |
virtual ~basic_istream();
|
| 24 |
|
| 25 |
+
// [istream.sentry], prefix/suffix
|
| 26 |
class sentry;
|
| 27 |
|
| 28 |
// [istream.formatted], formatted input
|
| 29 |
basic_istream<charT, traits>&
|
| 30 |
operator>>(basic_istream<charT, traits>& (*pf)(basic_istream<charT, traits>&));
|
|
|
|
| 74 |
basic_istream<charT, traits>& seekg(pos_type);
|
| 75 |
basic_istream<charT, traits>& seekg(off_type, ios_base::seekdir);
|
| 76 |
|
| 77 |
protected:
|
| 78 |
// [istream.cons], copy/move constructor
|
| 79 |
+
basic_istream(const basic_istream&) = delete;
|
| 80 |
basic_istream(basic_istream&& rhs);
|
| 81 |
|
| 82 |
// [istream.assign], assign and swap
|
| 83 |
+
basic_istream& operator=(const basic_istream&) = delete;
|
| 84 |
basic_istream& operator=(basic_istream&& rhs);
|
| 85 |
void swap(basic_istream& rhs);
|
| 86 |
};
|
| 87 |
|
| 88 |
// [istream.extractors], character extraction templates
|
|
|
|
| 91 |
template<class traits>
|
| 92 |
basic_istream<char, traits>& operator>>(basic_istream<char, traits>&, unsigned char&);
|
| 93 |
template<class traits>
|
| 94 |
basic_istream<char, traits>& operator>>(basic_istream<char, traits>&, signed char&);
|
| 95 |
|
| 96 |
+
template<class charT, class traits, size_t N>
|
| 97 |
+
basic_istream<charT, traits>& operator>>(basic_istream<charT, traits>&, charT(&)[N]);
|
| 98 |
+
template<class traits, size_t N>
|
| 99 |
+
basic_istream<char, traits>& operator>>(basic_istream<char, traits>&, unsigned char(&)[N]);
|
| 100 |
+
template<class traits, size_t N>
|
| 101 |
+
basic_istream<char, traits>& operator>>(basic_istream<char, traits>&, signed char(&)[N]);
|
| 102 |
}
|
| 103 |
```
|
| 104 |
|
| 105 |
The class template `basic_istream` defines a number of member function
|
| 106 |
signatures that assist in reading and interpreting input from sequences
|
|
|
|
| 113 |
or `rdbuf()->sgetc()`. They may use other public members of `istream`.
|
| 114 |
|
| 115 |
If `rdbuf()->sbumpc()` or `rdbuf()->sgetc()` returns `traits::eof()`,
|
| 116 |
then the input function, except as explicitly noted otherwise, completes
|
| 117 |
its actions and does `setstate(eofbit)`, which may throw
|
| 118 |
+
`ios_base::failure` [[iostate.flags]], before returning.
|
| 119 |
|
| 120 |
If one of these called functions throws an exception, then unless
|
| 121 |
+
explicitly noted otherwise, the input function sets `badbit` in the
|
| 122 |
+
error state. If `badbit` is set in `exceptions()`, the input function
|
| 123 |
+
rethrows the exception without completing its actions, otherwise it does
|
| 124 |
+
not throw anything and proceeds as if the called function had returned a
|
| 125 |
failure indication.
|
| 126 |
|
| 127 |
+
##### Constructors <a id="istream.cons">[[istream.cons]]</a>
|
| 128 |
|
| 129 |
``` cpp
|
| 130 |
explicit basic_istream(basic_streambuf<charT, traits>* sb);
|
| 131 |
```
|
| 132 |
|
| 133 |
+
*Effects:* Initializes the base class subobject with
|
| 134 |
+
`basic_ios::init(sb)` [[basic.ios.cons]].
|
|
|
|
| 135 |
|
| 136 |
+
*Ensures:* `gcount() == 0`.
|
| 137 |
|
| 138 |
``` cpp
|
| 139 |
basic_istream(basic_istream&& rhs);
|
| 140 |
```
|
| 141 |
|
| 142 |
+
*Effects:* Default constructs the base class, copies the `gcount()` from
|
| 143 |
+
`rhs`, calls `basic_ios<charT, traits>::move(rhs)` to initialize the
|
| 144 |
+
base class, and sets the `gcount()` for `rhs` to 0.
|
|
|
|
| 145 |
|
| 146 |
``` cpp
|
| 147 |
virtual ~basic_istream();
|
| 148 |
```
|
| 149 |
|
|
|
|
|
|
|
| 150 |
*Remarks:* Does not perform any operations of `rdbuf()`.
|
| 151 |
|
| 152 |
+
##### Assignment and swap <a id="istream.assign">[[istream.assign]]</a>
|
| 153 |
|
| 154 |
``` cpp
|
| 155 |
basic_istream& operator=(basic_istream&& rhs);
|
| 156 |
```
|
| 157 |
|
| 158 |
+
*Effects:* Equivalent to: `swap(rhs)`.
|
| 159 |
|
| 160 |
*Returns:* `*this`.
|
| 161 |
|
| 162 |
``` cpp
|
| 163 |
void swap(basic_istream& rhs);
|
| 164 |
```
|
| 165 |
|
| 166 |
*Effects:* Calls `basic_ios<charT, traits>::swap(rhs)`. Exchanges the
|
| 167 |
values returned by `gcount()` and `rhs.gcount()`.
|
| 168 |
|
| 169 |
+
##### Class `basic_istream::sentry` <a id="istream.sentry">[[istream.sentry]]</a>
|
| 170 |
|
| 171 |
``` cpp
|
| 172 |
namespace std {
|
| 173 |
template<class charT, class traits = char_traits<charT>>
|
| 174 |
class basic_istream<charT, traits>::sentry {
|
|
|
|
| 175 |
bool ok_; // exposition only
|
| 176 |
public:
|
| 177 |
explicit sentry(basic_istream<charT, traits>& is, bool noskipws = false);
|
| 178 |
~sentry();
|
| 179 |
explicit operator bool() const { return ok_; }
|
|
|
|
| 224 |
```
|
| 225 |
|
| 226 |
If, after any preparation is completed, `is.good()` is `true`,
|
| 227 |
`ok_ != false` otherwise, `ok_ == false`. During preparation, the
|
| 228 |
constructor may call `setstate(failbit)` (which may throw
|
| 229 |
+
`ios_base::failure` [[iostate.flags]]).[^19]
|
| 230 |
|
| 231 |
``` cpp
|
| 232 |
~sentry();
|
| 233 |
```
|
| 234 |
|
|
|
|
| 236 |
|
| 237 |
``` cpp
|
| 238 |
explicit operator bool() const;
|
| 239 |
```
|
| 240 |
|
| 241 |
+
*Returns:* `ok_`.
|
| 242 |
|
| 243 |
#### Formatted input functions <a id="istream.formatted">[[istream.formatted]]</a>
|
| 244 |
|
| 245 |
##### Common requirements <a id="istream.formatted.reqmts">[[istream.formatted.reqmts]]</a>
|
| 246 |
|
| 247 |
Each formatted input function begins execution by constructing an object
|
| 248 |
of class `sentry` with the `noskipws` (second) argument `false`. If the
|
| 249 |
`sentry` object returns `true`, when converted to a value of type
|
| 250 |
`bool`, the function endeavors to obtain the requested input. If an
|
| 251 |
+
exception is thrown during input then `ios_base::badbit` is turned
|
| 252 |
+
on[^20] in `*this`’s error state. If `(exceptions()&badbit) != 0` then
|
| 253 |
+
the exception is rethrown. In any case, the formatted input function
|
| 254 |
destroys the `sentry` object. If no exception has been thrown, it
|
| 255 |
returns `*this`.
|
| 256 |
|
| 257 |
##### Arithmetic extractors <a id="istream.formatted.arithmetic">[[istream.formatted.arithmetic]]</a>
|
| 258 |
|
|
|
|
| 269 |
operator>>(bool& val);
|
| 270 |
operator>>(void*& val);
|
| 271 |
```
|
| 272 |
|
| 273 |
As in the case of the inserters, these extractors depend on the locale’s
|
| 274 |
+
`num_get<>` [[locale.num.get]] object to perform parsing the input
|
| 275 |
stream data. These extractors behave as formatted input functions (as
|
| 276 |
described in [[istream.formatted.reqmts]]). After a sentry object is
|
| 277 |
constructed, the conversion occurs as if performed by the following code
|
| 278 |
fragment:
|
| 279 |
|
|
|
|
| 373 |
in [[istream.formatted.reqmts]]).
|
| 374 |
|
| 375 |
*Returns:* `*this`.
|
| 376 |
|
| 377 |
``` cpp
|
| 378 |
+
template<class charT, class traits, size_t N>
|
| 379 |
+
basic_istream<charT, traits>& operator>>(basic_istream<charT, traits>& in, charT (&s)[N]);
|
| 380 |
+
template<class traits, size_t N>
|
| 381 |
+
basic_istream<char, traits>& operator>>(basic_istream<char, traits>& in, unsigned char (&s)[N]);
|
| 382 |
+
template<class traits, size_t N>
|
| 383 |
+
basic_istream<char, traits>& operator>>(basic_istream<char, traits>& in, signed char (&s)[N]);
|
| 384 |
```
|
| 385 |
|
| 386 |
*Effects:* Behaves like a formatted input member (as described
|
| 387 |
in [[istream.formatted.reqmts]]) of `in`. After a `sentry` object is
|
| 388 |
+
constructed, `operator>>` extracts characters and stores them into `s`.
|
| 389 |
+
If `width()` is greater than zero, `n` is `min(size_t(width()), N)`.
|
| 390 |
+
Otherwise `n` is `N`. `n` is the maximum number of characters stored.
|
|
|
|
|
|
|
|
|
|
| 391 |
|
| 392 |
Characters are extracted and stored until any of the following occurs:
|
| 393 |
|
| 394 |
- `n-1` characters are stored;
|
| 395 |
- end of file occurs on the input sequence;
|
|
|
|
| 399 |
`operator>>` then stores a null byte (`charT()`) in the next position,
|
| 400 |
which may be the first position if no characters were extracted.
|
| 401 |
`operator>>` then calls `width(0)`.
|
| 402 |
|
| 403 |
If the function extracted no characters, it calls `setstate(failbit)`,
|
| 404 |
+
which may throw `ios_base::failure` [[iostate.flags]].
|
| 405 |
|
| 406 |
*Returns:* `in`.
|
| 407 |
|
| 408 |
``` cpp
|
| 409 |
template<class charT, class traits>
|
|
|
|
| 423 |
|
| 424 |
``` cpp
|
| 425 |
basic_istream<charT, traits>& operator>>(basic_streambuf<charT, traits>* sb);
|
| 426 |
```
|
| 427 |
|
| 428 |
+
*Effects:* Behaves as an unformatted input
|
| 429 |
+
function [[istream.unformatted]]. If `sb` is null, calls
|
| 430 |
+
`setstate(failbit)`, which may throw `ios_base::failure`
|
| 431 |
+
[[iostate.flags]]. After a sentry object is constructed, extracts
|
| 432 |
+
characters from `*this` and inserts them in the output sequence
|
| 433 |
+
controlled by `sb`. Characters are extracted and inserted until any of
|
| 434 |
+
the following occurs:
|
| 435 |
|
| 436 |
- end-of-file occurs on the input sequence;
|
| 437 |
- inserting in the output sequence fails (in which case the character to
|
| 438 |
be inserted is not extracted);
|
| 439 |
- an exception occurs (in which case the exception is caught).
|
| 440 |
|
| 441 |
If the function inserts no characters, it calls `setstate(failbit)`,
|
| 442 |
+
which may throw `ios_base::failure` [[iostate.flags]]. If it inserted no
|
| 443 |
+
characters because it caught an exception thrown while extracting
|
| 444 |
+
characters from `*this` and `failbit` is set in `exceptions()`
|
| 445 |
+
[[iostate.flags]], then the caught exception is rethrown.
|
|
|
|
| 446 |
|
| 447 |
*Returns:* `*this`.
|
| 448 |
|
| 449 |
#### Unformatted input functions <a id="istream.unformatted">[[istream.unformatted]]</a>
|
| 450 |
|
|
|
|
| 457 |
a value of type `bool`, the function returns without attempting to
|
| 458 |
obtain any input. In either case the number of extracted characters is
|
| 459 |
set to 0; unformatted input functions taking a character array of
|
| 460 |
nonzero size as an argument shall also store a null character (using
|
| 461 |
`charT()`) in the first location of the array. If an exception is thrown
|
| 462 |
+
during input then `ios_base::badbit` is turned on[^23] in `*this`’s
|
| 463 |
+
error state. (Exceptions thrown from `basic_ios<>::clear()` are not
|
| 464 |
+
caught or rethrown.) If `(exceptions()&badbit) != 0` then the exception
|
| 465 |
+
is rethrown. It also counts the number of characters extracted. If no
|
| 466 |
exception has been thrown it ends by storing the count in a member
|
| 467 |
object and returning the value specified. In any event the `sentry`
|
| 468 |
object is destroyed before leaving the unformatted input function.
|
| 469 |
|
| 470 |
``` cpp
|
|
|
|
| 482 |
```
|
| 483 |
|
| 484 |
*Effects:* Behaves as an unformatted input function (as described
|
| 485 |
above). After constructing a sentry object, extracts a character `c`, if
|
| 486 |
one is available. Otherwise, the function calls `setstate(failbit)`,
|
| 487 |
+
which may throw `ios_base::failure` [[iostate.flags]].
|
| 488 |
|
| 489 |
*Returns:* `c` if available, otherwise `traits::eof()`.
|
| 490 |
|
| 491 |
``` cpp
|
| 492 |
basic_istream<charT, traits>& get(char_type& c);
|
| 493 |
```
|
| 494 |
|
| 495 |
*Effects:* Behaves as an unformatted input function (as described
|
| 496 |
above). After constructing a sentry object, extracts a character, if one
|
| 497 |
is available, and assigns it to `c`.[^24] Otherwise, the function calls
|
| 498 |
+
`setstate(failbit)` (which may throw `ios_base::failure`
|
| 499 |
+
[[iostate.flags]]).
|
| 500 |
|
| 501 |
*Returns:* `*this`.
|
| 502 |
|
| 503 |
``` cpp
|
| 504 |
basic_istream<charT, traits>& get(char_type* s, streamsize n, char_type delim);
|
|
|
|
| 515 |
calls `setstate(eofbit)`);
|
| 516 |
- `traits::eq(c, delim)` for the next available input character `c` (in
|
| 517 |
which case `c` is not extracted).
|
| 518 |
|
| 519 |
If the function stores no characters, it calls `setstate(failbit)`
|
| 520 |
+
(which may throw `ios_base::failure` [[iostate.flags]]). In any case, if
|
| 521 |
+
`n` is greater than zero it then stores a null character into the next
|
| 522 |
+
successive location of the array.
|
| 523 |
|
| 524 |
*Returns:* `*this`.
|
| 525 |
|
| 526 |
``` cpp
|
| 527 |
basic_istream<charT, traits>& get(char_type* s, streamsize n);
|
|
|
|
| 547 |
which case `c` is not extracted);
|
| 548 |
- an exception occurs (in which case, the exception is caught but not
|
| 549 |
rethrown).
|
| 550 |
|
| 551 |
If the function inserts no characters, it calls `setstate(failbit)`,
|
| 552 |
+
which may throw `ios_base::failure` [[iostate.flags]].
|
| 553 |
|
| 554 |
*Returns:* `*this`.
|
| 555 |
|
| 556 |
``` cpp
|
| 557 |
basic_istream<charT, traits>& get(basic_streambuf<char_type, traits>& sb);
|
|
|
|
| 580 |
the function calls `setstate(failbit)`).
|
| 581 |
|
| 582 |
These conditions are tested in the order shown.[^28]
|
| 583 |
|
| 584 |
If the function extracts no characters, it calls `setstate(failbit)`
|
| 585 |
+
(which may throw `ios_base::failure` [[iostate.flags]]).[^29]
|
| 586 |
|
| 587 |
In any case, if `n` is greater than zero, it then stores a null
|
| 588 |
character (using `charT()`) into the next successive location of the
|
| 589 |
array.
|
| 590 |
|
|
|
|
| 632 |
*Effects:* Behaves as an unformatted input function (as described
|
| 633 |
above). After constructing a sentry object, extracts characters and
|
| 634 |
discards them. Characters are extracted until any of the following
|
| 635 |
occurs:
|
| 636 |
|
| 637 |
+
- `n != numeric_limits<streamsize>::max()` [[numeric.limits]] and `n`
|
| 638 |
characters have been extracted so far
|
| 639 |
- end-of-file occurs on the input sequence (in which case the function
|
| 640 |
+
calls `setstate(eofbit)`, which may throw `ios_base::failure`
|
| 641 |
+
[[iostate.flags]]);
|
| 642 |
- `traits::eq_int_type(traits::to_int_type(c), delim)` for the next
|
| 643 |
available input character `c` (in which case `c` is extracted).
|
| 644 |
|
| 645 |
*Remarks:* The last condition will never occur if
|
| 646 |
`traits::eq_int_type(delim, traits::eof())`.
|
|
|
|
| 670 |
extracted and stored until either of the following occurs:
|
| 671 |
|
| 672 |
- `n` characters are stored;
|
| 673 |
- end-of-file occurs on the input sequence (in which case the function
|
| 674 |
calls `setstate(failbit | eofbit)`, which may throw
|
| 675 |
+
`ios_base::failure` [[iostate.flags]]).
|
| 676 |
|
| 677 |
*Returns:* `*this`.
|
| 678 |
|
| 679 |
``` cpp
|
| 680 |
streamsize readsome(char_type* s, streamsize n);
|
|
|
|
| 684 |
above). After constructing a sentry object, if `!good()` calls
|
| 685 |
`setstate(failbit)` which may throw an exception, and return. Otherwise
|
| 686 |
extracts characters and stores them into successive locations of an
|
| 687 |
array whose first element is designated by `s`. If
|
| 688 |
`rdbuf()->in_avail() == -1`, calls `setstate(eofbit)` (which may throw
|
| 689 |
+
`ios_base::failure` [[iostate.flags]]), and extracts no characters;
|
| 690 |
|
| 691 |
- If `rdbuf()->in_avail() == 0`, extracts no characters
|
| 692 |
- If `rdbuf()->in_avail() > 0`, extracts `min(rdbuf()->in_avail(), n))`.
|
| 693 |
|
| 694 |
*Returns:* The number of characters extracted.
|
|
|
|
| 699 |
|
| 700 |
*Effects:* Behaves as an unformatted input function (as described
|
| 701 |
above), except that the function first clears `eofbit`. After
|
| 702 |
constructing a sentry object, if `!good()` calls `setstate(failbit)`
|
| 703 |
which may throw an exception, and return. If `rdbuf()` is not null,
|
| 704 |
+
calls `rdbuf()->sputbackc(c)`. If `rdbuf()` is null, or if `sputbackc`
|
| 705 |
returns `traits::eof()`, calls `setstate(badbit)` (which may throw
|
| 706 |
+
`ios_base::failure` [[iostate.flags]]).
|
| 707 |
|
| 708 |
[*Note 1*: This function extracts no characters, so the value returned
|
| 709 |
by the next call to `gcount()` is 0. — *end note*]
|
| 710 |
|
| 711 |
*Returns:* `*this`.
|
|
|
|
| 716 |
|
| 717 |
*Effects:* Behaves as an unformatted input function (as described
|
| 718 |
above), except that the function first clears `eofbit`. After
|
| 719 |
constructing a sentry object, if `!good()` calls `setstate(failbit)`
|
| 720 |
which may throw an exception, and return. If `rdbuf()` is not null,
|
| 721 |
+
calls `rdbuf()->sungetc()`. If `rdbuf()` is null, or if `sungetc`
|
| 722 |
returns `traits::eof()`, calls `setstate(badbit)` (which may throw
|
| 723 |
+
`ios_base::failure` [[iostate.flags]]).
|
| 724 |
|
| 725 |
[*Note 2*: This function extracts no characters, so the value returned
|
| 726 |
by the next call to `gcount()` is 0. — *end note*]
|
| 727 |
|
| 728 |
*Returns:* `*this`.
|
|
|
|
| 735 |
above), except that it does not count the number of characters extracted
|
| 736 |
and does not affect the value returned by subsequent calls to
|
| 737 |
`gcount()`. After constructing a sentry object, if `rdbuf()` is a null
|
| 738 |
pointer, returns `-1`. Otherwise, calls `rdbuf()->pubsync()` and, if
|
| 739 |
that function returns `-1` calls `setstate(badbit)` (which may throw
|
| 740 |
+
`ios_base::failure` [[iostate.flags]], and returns `-1`. Otherwise,
|
| 741 |
returns zero.
|
| 742 |
|
| 743 |
``` cpp
|
| 744 |
pos_type tellg();
|
| 745 |
```
|
|
|
|
| 783 |
|
| 784 |
*Returns:* `*this`.
|
| 785 |
|
| 786 |
#### Standard `basic_istream` manipulators <a id="istream.manip">[[istream.manip]]</a>
|
| 787 |
|
| 788 |
+
Each instantiation of the function template specified in this subclause
|
| 789 |
+
is a designated addressable function [[namespace.std]].
|
| 790 |
+
|
| 791 |
``` cpp
|
| 792 |
template<class charT, class traits>
|
| 793 |
basic_istream<charT, traits>& ws(basic_istream<charT, traits>& is);
|
| 794 |
```
|
| 795 |
|
| 796 |
+
*Effects:* Behaves as an unformatted input
|
| 797 |
+
function [[istream.unformatted]], except that it does not count the
|
| 798 |
+
number of characters extracted and does not affect the value returned by
|
| 799 |
+
subsequent calls to `is.gcount()`. After constructing a sentry object
|
| 800 |
extracts characters as long as the next available character `c` is
|
| 801 |
whitespace or until there are no more characters in the sequence.
|
| 802 |
Whitespace characters are distinguished with the same criterion as used
|
| 803 |
+
by `sentry::sentry` [[istream.sentry]]. If `ws` stops extracting
|
| 804 |
characters because there are no more available it sets `eofbit`, but not
|
| 805 |
`failbit`.
|
| 806 |
|
| 807 |
*Returns:* `is`.
|
| 808 |
|
| 809 |
#### Rvalue stream extraction <a id="istream.rvalue">[[istream.rvalue]]</a>
|
| 810 |
|
| 811 |
``` cpp
|
| 812 |
+
template<class Istream, class T>
|
| 813 |
+
Istream&& operator>>(Istream&& is, T&& x);
|
| 814 |
```
|
| 815 |
|
| 816 |
+
*Constraints:* The expression `is >> std::forward<T>(x)` is well-formed
|
| 817 |
+
when treated as an unevaluated operand and `Istream` is publicly and
|
| 818 |
+
unambiguously derived from `ios_base`.
|
| 819 |
+
|
| 820 |
*Effects:* Equivalent to:
|
| 821 |
|
| 822 |
``` cpp
|
| 823 |
is >> std::forward<T>(x);
|
| 824 |
+
return std::move(is);
|
| 825 |
```
|
| 826 |
|
|
|
|
|
|
|
|
|
|
| 827 |
#### Class template `basic_iostream` <a id="iostreamclass">[[iostreamclass]]</a>
|
| 828 |
|
| 829 |
``` cpp
|
| 830 |
namespace std {
|
| 831 |
template<class charT, class traits = char_traits<charT>>
|
|
|
|
| 845 |
// [iostream.dest], destructor
|
| 846 |
virtual ~basic_iostream();
|
| 847 |
|
| 848 |
protected:
|
| 849 |
// [iostream.cons], constructor
|
| 850 |
+
basic_iostream(const basic_iostream&) = delete;
|
| 851 |
basic_iostream(basic_iostream&& rhs);
|
| 852 |
|
| 853 |
// [iostream.assign], assign and swap
|
| 854 |
+
basic_iostream& operator=(const basic_iostream&) = delete;
|
| 855 |
basic_iostream& operator=(basic_iostream&& rhs);
|
| 856 |
void swap(basic_iostream& rhs);
|
| 857 |
};
|
| 858 |
}
|
| 859 |
```
|
| 860 |
|
| 861 |
The class template `basic_iostream` inherits a number of functions that
|
| 862 |
allow reading input and writing output to sequences controlled by a
|
| 863 |
stream buffer.
|
| 864 |
|
| 865 |
+
##### Constructors <a id="iostream.cons">[[iostream.cons]]</a>
|
| 866 |
|
| 867 |
``` cpp
|
| 868 |
explicit basic_iostream(basic_streambuf<charT, traits>* sb);
|
| 869 |
```
|
| 870 |
|
| 871 |
+
*Effects:* Initializes the base class subobjects with
|
| 872 |
+
`basic_istream<charT, traits>(sb)` [[istream]] and
|
| 873 |
+
`basic_ostream<charT, traits>(sb)` [[ostream]].
|
|
|
|
| 874 |
|
| 875 |
+
*Ensures:* `rdbuf() == sb` and `gcount() == 0`.
|
| 876 |
|
| 877 |
``` cpp
|
| 878 |
basic_iostream(basic_iostream&& rhs);
|
| 879 |
```
|
| 880 |
|
| 881 |
*Effects:* Move constructs from the rvalue `rhs` by constructing the
|
| 882 |
`basic_istream` base class with `move(rhs)`.
|
| 883 |
|
| 884 |
+
##### Destructor <a id="iostream.dest">[[iostream.dest]]</a>
|
| 885 |
|
| 886 |
``` cpp
|
| 887 |
virtual ~basic_iostream();
|
| 888 |
```
|
| 889 |
|
|
|
|
|
|
|
| 890 |
*Remarks:* Does not perform any operations on `rdbuf()`.
|
| 891 |
|
| 892 |
+
##### Assignment and swap <a id="iostream.assign">[[iostream.assign]]</a>
|
| 893 |
|
| 894 |
``` cpp
|
| 895 |
basic_iostream& operator=(basic_iostream&& rhs);
|
| 896 |
```
|
| 897 |
|
| 898 |
+
*Effects:* Equivalent to: `swap(rhs)`.
|
| 899 |
|
| 900 |
``` cpp
|
| 901 |
void swap(basic_iostream& rhs);
|
| 902 |
```
|
| 903 |
|