- tmp/tmp0c03tj9i/{from.md → to.md} +213 -222
tmp/tmp0c03tj9i/{from.md → to.md}
RENAMED
|
@@ -10,30 +10,30 @@ extracts from stream rvalues.
|
|
| 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 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
|
| 21 |
-
// [istream.cons]
|
| 22 |
explicit basic_istream(basic_streambuf<charT, traits>* sb);
|
| 23 |
virtual ~basic_istream();
|
| 24 |
|
| 25 |
-
// [istream::sentry]
|
| 26 |
class sentry;
|
| 27 |
|
| 28 |
-
// [istream.formatted]
|
| 29 |
-
basic_istream<charT,traits>&
|
| 30 |
-
basic_istream<charT,traits>& (*pf)(basic_istream<charT,traits>&));
|
| 31 |
-
basic_istream<charT,traits>&
|
| 32 |
-
|
| 33 |
-
basic_istream<charT,traits>&
|
| 34 |
-
ios_base& (*pf)(ios_base&));
|
| 35 |
|
| 36 |
basic_istream<charT, traits>& operator>>(bool& n);
|
| 37 |
basic_istream<charT, traits>& operator>>(short& n);
|
| 38 |
basic_istream<charT, traits>& operator>>(unsigned short& n);
|
| 39 |
basic_istream<charT, traits>& operator>>(int& n);
|
|
@@ -45,30 +45,25 @@ namespace std {
|
|
| 45 |
basic_istream<charT, traits>& operator>>(float& f);
|
| 46 |
basic_istream<charT, traits>& operator>>(double& f);
|
| 47 |
basic_istream<charT, traits>& operator>>(long double& f);
|
| 48 |
|
| 49 |
basic_istream<charT, traits>& operator>>(void*& p);
|
| 50 |
-
basic_istream<charT,traits>& operator>>(
|
| 51 |
-
basic_streambuf<char_type,traits>* sb);
|
| 52 |
|
| 53 |
-
// [istream.unformatted]
|
| 54 |
streamsize gcount() const;
|
| 55 |
int_type get();
|
| 56 |
basic_istream<charT, traits>& get(char_type& c);
|
| 57 |
basic_istream<charT, traits>& get(char_type* s, streamsize n);
|
| 58 |
-
basic_istream<charT,traits>& get(char_type* s, streamsize n,
|
| 59 |
-
char_type delim);
|
| 60 |
basic_istream<charT, traits>& get(basic_streambuf<char_type, traits>& sb);
|
| 61 |
-
basic_istream<charT,traits>& get(basic_streambuf<char_type,traits>& sb,
|
| 62 |
-
char_type delim);
|
| 63 |
|
| 64 |
basic_istream<charT, traits>& getline(char_type* s, streamsize n);
|
| 65 |
-
basic_istream<charT,traits>& getline(char_type* s, streamsize n,
|
| 66 |
-
char_type delim);
|
| 67 |
|
| 68 |
-
basic_istream<charT,traits>& ignore(
|
| 69 |
-
streamsize n = 1, int_type delim = traits::eof());
|
| 70 |
int_type peek();
|
| 71 |
basic_istream<charT, traits>& read (char_type* s, streamsize n);
|
| 72 |
streamsize readsome(char_type* s, streamsize n);
|
| 73 |
|
| 74 |
basic_istream<charT, traits>& putback(char_type c);
|
|
@@ -78,45 +73,40 @@ namespace std {
|
|
| 78 |
pos_type tellg();
|
| 79 |
basic_istream<charT, traits>& seekg(pos_type);
|
| 80 |
basic_istream<charT, traits>& seekg(off_type, ios_base::seekdir);
|
| 81 |
|
| 82 |
protected:
|
|
|
|
| 83 |
basic_istream(const basic_istream& rhs) = delete;
|
| 84 |
basic_istream(basic_istream&& rhs);
|
| 85 |
|
| 86 |
-
// [istream.assign]
|
| 87 |
basic_istream& operator=(const basic_istream& rhs) = delete;
|
| 88 |
basic_istream& operator=(basic_istream&& rhs);
|
| 89 |
void swap(basic_istream& rhs);
|
| 90 |
};
|
| 91 |
|
| 92 |
-
// [istream
|
| 93 |
template<class charT, class traits>
|
| 94 |
-
basic_istream<charT,traits>& operator>>(basic_istream<charT,traits>&,
|
| 95 |
-
charT&);
|
| 96 |
template<class traits>
|
| 97 |
-
basic_istream<char,traits>& operator>>(basic_istream<char,traits>&,
|
| 98 |
-
unsigned char&);
|
| 99 |
template<class traits>
|
| 100 |
-
basic_istream<char,traits>& operator>>(basic_istream<char,traits>&,
|
| 101 |
-
signed char&);
|
| 102 |
|
| 103 |
template<class charT, class traits>
|
| 104 |
-
basic_istream<charT,traits>& operator>>(basic_istream<charT,traits>&,
|
| 105 |
-
charT*);
|
| 106 |
template<class traits>
|
| 107 |
-
basic_istream<char,traits>& operator>>(basic_istream<char,traits>&,
|
| 108 |
-
unsigned char*);
|
| 109 |
template<class traits>
|
| 110 |
-
basic_istream<char,traits>& operator>>(basic_istream<char,traits>&,
|
| 111 |
-
signed char*);
|
| 112 |
}
|
| 113 |
```
|
| 114 |
|
| 115 |
-
The class `basic_istream` defines a number of member function
|
| 116 |
-
that assist in reading and interpreting input from sequences
|
| 117 |
-
by a stream buffer.
|
| 118 |
|
| 119 |
Two groups of member function signatures share common properties: the
|
| 120 |
*formatted input functions* (or *extractors*) and the *unformatted input
|
| 121 |
functions.* Both groups of input functions are described as if they
|
| 122 |
obtain (or *extract*) input *characters* by calling `rdbuf()->sbumpc()`
|
|
@@ -138,15 +128,15 @@ failure indication.
|
|
| 138 |
|
| 139 |
``` cpp
|
| 140 |
explicit basic_istream(basic_streambuf<charT, traits>* sb);
|
| 141 |
```
|
| 142 |
|
| 143 |
-
*Effects:* Constructs an object of class `basic_istream`,
|
| 144 |
-
|
| 145 |
`basic_ios::init(sb)` ([[basic.ios.cons]]).
|
| 146 |
|
| 147 |
-
`gcount() == 0`
|
| 148 |
|
| 149 |
``` cpp
|
| 150 |
basic_istream(basic_istream&& rhs);
|
| 151 |
```
|
| 152 |
|
|
@@ -167,11 +157,11 @@ virtual ~basic_istream();
|
|
| 167 |
|
| 168 |
``` cpp
|
| 169 |
basic_istream& operator=(basic_istream&& rhs);
|
| 170 |
```
|
| 171 |
|
| 172 |
-
*Effects:* `swap(rhs)
|
| 173 |
|
| 174 |
*Returns:* `*this`.
|
| 175 |
|
| 176 |
``` cpp
|
| 177 |
void swap(basic_istream& rhs);
|
|
@@ -184,11 +174,11 @@ values returned by `gcount()` and `rhs.gcount()`.
|
|
| 184 |
|
| 185 |
``` cpp
|
| 186 |
namespace std {
|
| 187 |
template <class charT, class traits = char_traits<charT>>
|
| 188 |
class basic_istream<charT, traits>::sentry {
|
| 189 |
-
|
| 190 |
bool ok_; // exposition only
|
| 191 |
public:
|
| 192 |
explicit sentry(basic_istream<charT, traits>& is, bool noskipws = false);
|
| 193 |
~sentry();
|
| 194 |
explicit operator bool() const { return ok_; }
|
|
@@ -211,19 +201,23 @@ Otherwise, prepares for formatted or unformatted input. First, if
|
|
| 211 |
to synchronize the output sequence with any associated external C
|
| 212 |
stream. Except that this call can be suppressed if the put area of
|
| 213 |
`is.tie()` is empty. Further an implementation is allowed to defer the
|
| 214 |
call to `flush` until a call of `is.rdbuf()->underflow()` occurs. If no
|
| 215 |
such call occurs before the `sentry` object is destroyed, the call to
|
| 216 |
-
`flush` may be eliminated entirely.[^
|
| 217 |
`is.flags() & ios_base::skipws` is nonzero, the function extracts and
|
| 218 |
discards each character as long as the next available input character
|
| 219 |
`c` is a whitespace character. If `is.rdbuf()->sbumpc()` or
|
| 220 |
`is.rdbuf()->sgetc()` returns `traits::eof()`, the function calls
|
| 221 |
`setstate(failbit | eofbit)` (which may throw `ios_base::failure`).
|
| 222 |
|
| 223 |
*Remarks:* The constructor
|
| 224 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 225 |
uses the currently imbued locale in `is`, to determine whether the next
|
| 226 |
input character is whitespace or not.
|
| 227 |
|
| 228 |
To decide if the character `c` is a whitespace character, the
|
| 229 |
constructor performs as if it executes the following code fragment:
|
|
@@ -235,11 +229,11 @@ if (ctype.is(ctype.space,c)!=0)
|
|
| 235 |
```
|
| 236 |
|
| 237 |
If, after any preparation is completed, `is.good()` is `true`,
|
| 238 |
`ok_ != false` otherwise, `ok_ == false`. During preparation, the
|
| 239 |
constructor may call `setstate(failbit)` (which may throw
|
| 240 |
-
`ios_base::failure` ([[iostate.flags]]))[^
|
| 241 |
|
| 242 |
``` cpp
|
| 243 |
~sentry();
|
| 244 |
```
|
| 245 |
|
|
@@ -257,11 +251,11 @@ explicit operator bool() const;
|
|
| 257 |
|
| 258 |
Each formatted input function begins execution by constructing an object
|
| 259 |
of class `sentry` with the `noskipws` (second) argument `false`. If the
|
| 260 |
`sentry` object returns `true`, when converted to a value of type
|
| 261 |
`bool`, the function endeavors to obtain the requested input. If an
|
| 262 |
-
exception is thrown during input then `ios::badbit` is turned on[^
|
| 263 |
`*this`’s error state. If `(exceptions()&badbit) != 0` then the
|
| 264 |
exception is rethrown. In any case, the formatted input function
|
| 265 |
destroys the `sentry` object. If no exception has been thrown, it
|
| 266 |
returns `*this`.
|
| 267 |
|
|
@@ -287,32 +281,36 @@ stream data. These extractors behave as formatted input functions (as
|
|
| 287 |
described in [[istream.formatted.reqmts]]). After a sentry object is
|
| 288 |
constructed, the conversion occurs as if performed by the following code
|
| 289 |
fragment:
|
| 290 |
|
| 291 |
``` cpp
|
| 292 |
-
|
| 293 |
iostate err = iostate::goodbit;
|
| 294 |
use_facet<numget>(loc).get(*this, 0, *this, err, val);
|
| 295 |
setstate(err);
|
| 296 |
```
|
| 297 |
|
| 298 |
In the above fragment, `loc` stands for the private member of the
|
| 299 |
-
`basic_ios` class.
|
|
|
|
|
|
|
| 300 |
`istreambuf_iterator` class which is an iterator pointed to an input
|
| 301 |
-
stream. It bypasses istreams and uses streambufs
|
| 302 |
-
|
| 303 |
-
|
|
|
|
|
|
|
| 304 |
|
| 305 |
``` cpp
|
| 306 |
operator>>(short& val);
|
| 307 |
```
|
| 308 |
|
| 309 |
The conversion occurs as if performed by the following code fragment
|
| 310 |
(using the same notation as for the preceding code fragment):
|
| 311 |
|
| 312 |
``` cpp
|
| 313 |
-
|
| 314 |
iostate err = ios_base::goodbit;
|
| 315 |
long lval;
|
| 316 |
use_facet<numget>(loc).get(*this, 0, *this, err, lval);
|
| 317 |
if (lval < numeric_limits<short>::min()) {
|
| 318 |
err |= ios_base::failbit;
|
|
@@ -331,11 +329,11 @@ operator>>(int& val);
|
|
| 331 |
|
| 332 |
The conversion occurs as if performed by the following code fragment
|
| 333 |
(using the same notation as for the preceding code fragment):
|
| 334 |
|
| 335 |
``` cpp
|
| 336 |
-
|
| 337 |
iostate err = ios_base::goodbit;
|
| 338 |
long lval;
|
| 339 |
use_facet<numget>(loc).get(*this, 0, *this, err, lval);
|
| 340 |
if (lval < numeric_limits<int>::min()) {
|
| 341 |
err |= ios_base::failbit;
|
|
@@ -346,54 +344,50 @@ if (lval < numeric_limits<int>::min()) {
|
|
| 346 |
} else
|
| 347 |
val = static_cast<int>(lval);
|
| 348 |
setstate(err);
|
| 349 |
```
|
| 350 |
|
| 351 |
-
##### `basic_istream::operator>>` <a id="istream
|
| 352 |
|
| 353 |
``` cpp
|
| 354 |
-
basic_istream<charT,traits>&
|
| 355 |
-
|
| 356 |
```
|
| 357 |
|
| 358 |
*Effects:* None. This extractor does not behave as a formatted input
|
| 359 |
-
function (as described in [[istream.formatted.reqmts]]
|
| 360 |
|
| 361 |
-
*Returns:* `pf(*this)`.[^
|
| 362 |
|
| 363 |
``` cpp
|
| 364 |
-
basic_istream<charT,traits>&
|
| 365 |
-
|
| 366 |
```
|
| 367 |
|
| 368 |
*Effects:* Calls `pf(*this)`. This extractor does not behave as a
|
| 369 |
formatted input function (as described
|
| 370 |
in [[istream.formatted.reqmts]]).
|
| 371 |
|
| 372 |
*Returns:* `*this`.
|
| 373 |
|
| 374 |
``` cpp
|
| 375 |
-
basic_istream<charT,traits>& operator>>
|
| 376 |
-
(ios_base& (*pf)(ios_base&));
|
| 377 |
```
|
| 378 |
|
| 379 |
-
*Effects:* Calls `pf(*this)`.[^
|
| 380 |
formatted input function (as described
|
| 381 |
in [[istream.formatted.reqmts]]).
|
| 382 |
|
| 383 |
*Returns:* `*this`.
|
| 384 |
|
| 385 |
``` cpp
|
| 386 |
template<class charT, class traits>
|
| 387 |
-
basic_istream<charT,traits>& operator>>(basic_istream<charT,traits>& in,
|
| 388 |
-
charT* s);
|
| 389 |
template<class traits>
|
| 390 |
-
basic_istream<char,traits>& operator>>(basic_istream<char,traits>& in,
|
| 391 |
-
unsigned char* s);
|
| 392 |
template<class traits>
|
| 393 |
-
basic_istream<char,traits>& operator>>(basic_istream<char,traits>& in,
|
| 394 |
-
signed char* s);
|
| 395 |
```
|
| 396 |
|
| 397 |
*Effects:* Behaves like a formatted input member (as described
|
| 398 |
in [[istream.formatted.reqmts]]) of `in`. After a `sentry` object is
|
| 399 |
constructed, `operator>>` extracts characters and stores them into
|
|
@@ -405,12 +399,12 @@ stored.
|
|
| 405 |
|
| 406 |
Characters are extracted and stored until any of the following occurs:
|
| 407 |
|
| 408 |
- `n-1` characters are stored;
|
| 409 |
- end of file occurs on the input sequence;
|
| 410 |
-
- `ct
|
| 411 |
-
`
|
| 412 |
|
| 413 |
`operator>>` then stores a null byte (`charT()`) in the next position,
|
| 414 |
which may be the first position if no characters were extracted.
|
| 415 |
`operator>>` then calls `width(0)`.
|
| 416 |
|
|
@@ -419,38 +413,33 @@ which may throw `ios_base::failure` ([[iostate.flags]]).
|
|
| 419 |
|
| 420 |
*Returns:* `in`.
|
| 421 |
|
| 422 |
``` cpp
|
| 423 |
template<class charT, class traits>
|
| 424 |
-
basic_istream<charT,traits>& operator>>(basic_istream<charT,traits>& in,
|
| 425 |
-
charT& c);
|
| 426 |
template<class traits>
|
| 427 |
-
basic_istream<char,traits>& operator>>(basic_istream<char,traits>& in,
|
| 428 |
-
unsigned char& c);
|
| 429 |
template<class traits>
|
| 430 |
-
basic_istream<char,traits>& operator>>(basic_istream<char,traits>& in,
|
| 431 |
-
signed char& c);
|
| 432 |
```
|
| 433 |
|
| 434 |
*Effects:* Behaves like a formatted input member (as described
|
| 435 |
in [[istream.formatted.reqmts]]) of `in`. After a `sentry` object is
|
| 436 |
constructed a character is extracted from `in`, if one is available, and
|
| 437 |
stored in `c`. Otherwise, the function calls `in.setstate(failbit)`.
|
| 438 |
|
| 439 |
*Returns:* `in`.
|
| 440 |
|
| 441 |
``` cpp
|
| 442 |
-
basic_istream<charT,traits>& operator>>
|
| 443 |
-
(basic_streambuf<charT,traits>* sb);
|
| 444 |
```
|
| 445 |
|
| 446 |
-
*Effects:* Behaves as an unformatted input function
|
| 447 |
-
|
| 448 |
-
`
|
| 449 |
-
|
| 450 |
-
|
| 451 |
-
output sequence controlled by `sb`. Characters are extracted and
|
| 452 |
inserted until any of the following occurs:
|
| 453 |
|
| 454 |
- end-of-file occurs on the input sequence;
|
| 455 |
- inserting in the output sequence fails (in which case the character to
|
| 456 |
be inserted is not extracted);
|
|
@@ -470,18 +459,18 @@ rethrown.
|
|
| 470 |
Each unformatted input function begins execution by constructing an
|
| 471 |
object of class `sentry` with the default argument `noskipws` (second)
|
| 472 |
argument `true`. If the `sentry` object returns `true`, when converted
|
| 473 |
to a value of type `bool`, the function endeavors to obtain the
|
| 474 |
requested input. Otherwise, if the sentry constructor exits by throwing
|
| 475 |
-
an exception or if the sentry object returns false, when converted to
|
| 476 |
-
value of type `bool`, the function returns without attempting to
|
| 477 |
-
any input. In either case the number of extracted characters is
|
| 478 |
-
0; unformatted input functions taking a character array of
|
| 479 |
-
as an argument shall also store a null character (using
|
| 480 |
-
the first location of the array. If an exception is thrown
|
| 481 |
-
then `ios::badbit` is turned on[^
|
| 482 |
-
(Exceptions thrown from `basic_ios<>::clear()` are not caught or
|
| 483 |
rethrown.) If `(exceptions()&badbit) != 0` then the exception is
|
| 484 |
rethrown. It also counts the number of characters extracted. If no
|
| 485 |
exception has been thrown it ends by storing the count in a member
|
| 486 |
object and returning the value specified. In any event the `sentry`
|
| 487 |
object is destroyed before leaving the unformatted input function.
|
|
@@ -489,49 +478,47 @@ object is destroyed before leaving the unformatted input function.
|
|
| 489 |
``` cpp
|
| 490 |
streamsize gcount() const;
|
| 491 |
```
|
| 492 |
|
| 493 |
*Effects:* None. This member function does not behave as an unformatted
|
| 494 |
-
input function (as described
|
| 495 |
|
| 496 |
*Returns:* The number of characters extracted by the last unformatted
|
| 497 |
input member function called for the object.
|
| 498 |
|
| 499 |
``` cpp
|
| 500 |
int_type get();
|
| 501 |
```
|
| 502 |
|
| 503 |
*Effects:* Behaves as an unformatted input function (as described
|
| 504 |
-
|
| 505 |
-
|
| 506 |
-
|
| 507 |
-
`ios_base::failure` ([[iostate.flags]]),
|
| 508 |
|
| 509 |
*Returns:* `c` if available, otherwise `traits::eof()`.
|
| 510 |
|
| 511 |
``` cpp
|
| 512 |
basic_istream<charT, traits>& get(char_type& c);
|
| 513 |
```
|
| 514 |
|
| 515 |
*Effects:* Behaves as an unformatted input function (as described
|
| 516 |
-
|
| 517 |
-
|
| 518 |
-
`
|
| 519 |
-
|
| 520 |
|
| 521 |
*Returns:* `*this`.
|
| 522 |
|
| 523 |
``` cpp
|
| 524 |
-
basic_istream<charT,traits>& get(char_type* s, streamsize n,
|
| 525 |
-
char_type delim );
|
| 526 |
```
|
| 527 |
|
| 528 |
*Effects:* Behaves as an unformatted input function (as described
|
| 529 |
-
|
| 530 |
-
|
| 531 |
-
|
| 532 |
-
|
| 533 |
|
| 534 |
- `n` is less than one or `n - 1` characters are stored;
|
| 535 |
- end-of-file occurs on the input sequence (in which case the function
|
| 536 |
calls `setstate(eofbit)`);
|
| 537 |
- `traits::eq(c, delim)` for the next available input character `c` (in
|
|
@@ -546,24 +533,22 @@ next successive location of the array.
|
|
| 546 |
|
| 547 |
``` cpp
|
| 548 |
basic_istream<charT, traits>& get(char_type* s, streamsize n);
|
| 549 |
```
|
| 550 |
|
| 551 |
-
*Effects:* Calls `get(s,n,widen(’\n’))`
|
| 552 |
|
| 553 |
*Returns:* Value returned by the call.
|
| 554 |
|
| 555 |
``` cpp
|
| 556 |
-
basic_istream<charT,traits>& get(basic_streambuf<char_type,traits>& sb,
|
| 557 |
-
char_type delim );
|
| 558 |
```
|
| 559 |
|
| 560 |
*Effects:* Behaves as an unformatted input function (as described
|
| 561 |
-
|
| 562 |
-
|
| 563 |
-
|
| 564 |
-
the following occurs:
|
| 565 |
|
| 566 |
- end-of-file occurs on the input sequence;
|
| 567 |
- inserting in the output sequence fails (in which case the character to
|
| 568 |
be inserted is not extracted);
|
| 569 |
- `traits::eq(c, delim)` for the next available input character `c` (in
|
|
@@ -578,44 +563,45 @@ which may throw `ios_base::failure` ([[iostate.flags]]).
|
|
| 578 |
|
| 579 |
``` cpp
|
| 580 |
basic_istream<charT, traits>& get(basic_streambuf<char_type, traits>& sb);
|
| 581 |
```
|
| 582 |
|
| 583 |
-
*Effects:* Calls `get(sb, widen(’\n’))`
|
| 584 |
|
| 585 |
*Returns:* Value returned by the call.
|
| 586 |
|
| 587 |
``` cpp
|
| 588 |
-
basic_istream<charT,traits>& getline(char_type* s, streamsize n,
|
| 589 |
-
char_type delim);
|
| 590 |
```
|
| 591 |
|
| 592 |
*Effects:* Behaves as an unformatted input function (as described
|
| 593 |
-
|
| 594 |
-
|
| 595 |
-
|
| 596 |
-
|
| 597 |
|
| 598 |
1. end-of-file occurs on the input sequence (in which case the function
|
| 599 |
calls `setstate(eofbit)`);
|
| 600 |
2. `traits::eq(c, delim)` for the next available input character `c`
|
| 601 |
(in which case the input character is extracted but not
|
| 602 |
-
stored);[^
|
| 603 |
3. `n` is less than one or `n - 1` characters are stored (in which case
|
| 604 |
the function calls `setstate(failbit)`).
|
| 605 |
|
| 606 |
-
These conditions are tested in the order shown.[^
|
| 607 |
|
| 608 |
If the function extracts no characters, it calls `setstate(failbit)`
|
| 609 |
-
(which may throw `ios_base::failure` ([[iostate.flags]])).[^
|
| 610 |
|
| 611 |
In any case, if `n` is greater than zero, it then stores a null
|
| 612 |
character (using `charT()`) into the next successive location of the
|
| 613 |
array.
|
| 614 |
|
| 615 |
*Returns:* `*this`.
|
| 616 |
|
|
|
|
|
|
|
| 617 |
``` cpp
|
| 618 |
#include <iostream>
|
| 619 |
|
| 620 |
int main() {
|
| 621 |
using namespace std;
|
|
@@ -637,27 +623,28 @@ int main() {
|
|
| 637 |
cout << " (" << count << " chars): " << buffer << endl;
|
| 638 |
}
|
| 639 |
}
|
| 640 |
```
|
| 641 |
|
|
|
|
|
|
|
| 642 |
``` cpp
|
| 643 |
basic_istream<charT, traits>& getline(char_type* s, streamsize n);
|
| 644 |
```
|
| 645 |
|
| 646 |
*Returns:* `getline(s, n, widen(’\n’))`
|
| 647 |
|
| 648 |
``` cpp
|
| 649 |
-
basic_istream<charT,traits>&
|
| 650 |
-
ignore(streamsize n = 1, int_type delim = traits::eof());
|
| 651 |
```
|
| 652 |
|
| 653 |
*Effects:* Behaves as an unformatted input function (as described
|
| 654 |
-
|
| 655 |
-
|
| 656 |
-
|
| 657 |
|
| 658 |
-
- `n != numeric_limits<streamsize>::max()` ([[limits]]) and `n`
|
| 659 |
characters have been extracted so far
|
| 660 |
- end-of-file occurs on the input sequence (in which case the function
|
| 661 |
calls `setstate(eofbit)`, which may throw
|
| 662 |
`ios_base::failure` ([[iostate.flags]]));
|
| 663 |
- `traits::eq_int_type(traits::to_int_type(c), delim)` for the next
|
|
@@ -671,27 +658,26 @@ until any of the following occurs:
|
|
| 671 |
``` cpp
|
| 672 |
int_type peek();
|
| 673 |
```
|
| 674 |
|
| 675 |
*Effects:* Behaves as an unformatted input function (as described
|
| 676 |
-
|
| 677 |
-
|
| 678 |
|
| 679 |
*Returns:* `traits::eof()` if `good()` is `false`. Otherwise, returns
|
| 680 |
`rdbuf()->sgetc()`.
|
| 681 |
|
| 682 |
``` cpp
|
| 683 |
basic_istream<charT, traits>& read(char_type* s, streamsize n);
|
| 684 |
```
|
| 685 |
|
| 686 |
*Effects:* Behaves as an unformatted input function (as described
|
| 687 |
-
|
| 688 |
-
|
| 689 |
-
|
| 690 |
-
|
| 691 |
-
|
| 692 |
-
following occurs:
|
| 693 |
|
| 694 |
- `n` characters are stored;
|
| 695 |
- end-of-file occurs on the input sequence (in which case the function
|
| 696 |
calls `setstate(failbit | eofbit)`, which may throw
|
| 697 |
`ios_base::failure` ([[iostate.flags]])).
|
|
@@ -701,17 +687,16 @@ following occurs:
|
|
| 701 |
``` cpp
|
| 702 |
streamsize readsome(char_type* s, streamsize n);
|
| 703 |
```
|
| 704 |
|
| 705 |
*Effects:* Behaves as an unformatted input function (as described
|
| 706 |
-
|
| 707 |
-
|
| 708 |
-
|
| 709 |
-
|
| 710 |
-
|
| 711 |
-
|
| 712 |
-
characters;
|
| 713 |
|
| 714 |
- If `rdbuf()->in_avail() == 0`, extracts no characters
|
| 715 |
- If `rdbuf()->in_avail() > 0`, extracts `min(rdbuf()->in_avail(), n))`.
|
| 716 |
|
| 717 |
*Returns:* The number of characters extracted.
|
|
@@ -719,86 +704,87 @@ characters;
|
|
| 719 |
``` cpp
|
| 720 |
basic_istream<charT, traits>& putback(char_type c);
|
| 721 |
```
|
| 722 |
|
| 723 |
*Effects:* Behaves as an unformatted input function (as described
|
| 724 |
-
|
| 725 |
-
|
| 726 |
-
|
| 727 |
-
|
| 728 |
-
|
| 729 |
-
|
| 730 |
-
|
| 731 |
-
|
|
|
|
| 732 |
|
| 733 |
*Returns:* `*this`.
|
| 734 |
|
| 735 |
``` cpp
|
| 736 |
basic_istream<charT, traits>& unget();
|
| 737 |
```
|
| 738 |
|
| 739 |
*Effects:* Behaves as an unformatted input function (as described
|
| 740 |
-
|
| 741 |
-
|
| 742 |
-
|
| 743 |
-
|
| 744 |
-
|
| 745 |
-
|
| 746 |
-
|
| 747 |
-
|
|
|
|
| 748 |
|
| 749 |
*Returns:* `*this`.
|
| 750 |
|
| 751 |
``` cpp
|
| 752 |
int sync();
|
| 753 |
```
|
| 754 |
|
| 755 |
*Effects:* Behaves as an unformatted input function (as described
|
| 756 |
-
|
| 757 |
-
|
| 758 |
-
|
| 759 |
-
|
| 760 |
-
|
| 761 |
-
`setstate(badbit)` (which may throw
|
| 762 |
`ios_base::failure` ([[iostate.flags]]), and returns `-1`. Otherwise,
|
| 763 |
returns zero.
|
| 764 |
|
| 765 |
``` cpp
|
| 766 |
pos_type tellg();
|
| 767 |
```
|
| 768 |
|
| 769 |
*Effects:* Behaves as an unformatted input function (as described
|
| 770 |
-
|
| 771 |
-
|
| 772 |
-
|
| 773 |
|
| 774 |
*Returns:* After constructing a sentry object, if `fail() != false`,
|
| 775 |
returns `pos_type(-1)` to indicate failure. Otherwise, returns
|
| 776 |
`rdbuf()->pubseekoff(0, cur, in)`.
|
| 777 |
|
| 778 |
``` cpp
|
| 779 |
basic_istream<charT, traits>& seekg(pos_type pos);
|
| 780 |
```
|
| 781 |
|
| 782 |
*Effects:* Behaves as an unformatted input function (as described
|
| 783 |
-
|
| 784 |
-
|
| 785 |
-
|
| 786 |
-
|
| 787 |
-
|
| 788 |
-
|
| 789 |
`ios_base::failure`).
|
| 790 |
|
| 791 |
*Returns:* `*this`.
|
| 792 |
|
| 793 |
``` cpp
|
| 794 |
basic_istream<charT, traits>& seekg(off_type off, ios_base::seekdir dir);
|
| 795 |
```
|
| 796 |
|
| 797 |
*Effects:* Behaves as an unformatted input function (as described
|
| 798 |
-
|
| 799 |
-
the number of characters extracted and does not affect the value
|
| 800 |
returned by subsequent calls to `gcount()`. After constructing a sentry
|
| 801 |
object, if `fail() != true`, executes
|
| 802 |
`rdbuf()->pubseekoff(off, dir, ios_base::in)`. In case of failure, the
|
| 803 |
function calls `setstate(failbit)` (which may throw
|
| 804 |
`ios_base::failure`).
|
|
@@ -806,77 +792,94 @@ function calls `setstate(failbit)` (which may throw
|
|
| 806 |
*Returns:* `*this`.
|
| 807 |
|
| 808 |
#### Standard `basic_istream` manipulators <a id="istream.manip">[[istream.manip]]</a>
|
| 809 |
|
| 810 |
``` cpp
|
| 811 |
-
namespace std {
|
| 812 |
template <class charT, class traits>
|
| 813 |
basic_istream<charT, traits>& ws(basic_istream<charT, traits>& is);
|
| 814 |
-
}
|
| 815 |
```
|
| 816 |
|
| 817 |
-
*Effects:* Behaves as an unformatted input function
|
| 818 |
-
|
| 819 |
-
|
| 820 |
-
|
| 821 |
-
|
| 822 |
-
|
| 823 |
Whitespace characters are distinguished with the same criterion as used
|
| 824 |
by `sentry::sentry` ([[istream::sentry]]). If `ws` stops extracting
|
| 825 |
characters because there are no more available it sets `eofbit`, but not
|
| 826 |
`failbit`.
|
| 827 |
|
| 828 |
*Returns:* `is`.
|
| 829 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 830 |
#### Class template `basic_iostream` <a id="iostreamclass">[[iostreamclass]]</a>
|
| 831 |
|
| 832 |
``` cpp
|
| 833 |
namespace std {
|
| 834 |
template <class charT, class traits = char_traits<charT>>
|
| 835 |
-
class basic_iostream
|
| 836 |
-
public basic_istream<charT,traits>,
|
| 837 |
public basic_ostream<charT, traits> {
|
| 838 |
public:
|
| 839 |
-
|
| 840 |
-
|
| 841 |
-
|
| 842 |
-
|
| 843 |
-
|
| 844 |
-
typedef traits traits_type;
|
| 845 |
|
| 846 |
-
// constructor
|
| 847 |
explicit basic_iostream(basic_streambuf<charT, traits>* sb);
|
|
|
|
|
|
|
| 848 |
virtual ~basic_iostream();
|
| 849 |
|
| 850 |
protected:
|
|
|
|
| 851 |
basic_iostream(const basic_iostream& rhs) = delete;
|
| 852 |
basic_iostream(basic_iostream&& rhs);
|
| 853 |
|
| 854 |
-
// assign
|
| 855 |
basic_iostream& operator=(const basic_iostream& rhs) = delete;
|
| 856 |
basic_iostream& operator=(basic_iostream&& rhs);
|
| 857 |
void swap(basic_iostream& rhs);
|
| 858 |
};
|
| 859 |
}
|
| 860 |
```
|
| 861 |
|
| 862 |
-
The class `basic_iostream` inherits a number of functions that
|
| 863 |
-
reading input and writing output to sequences controlled by a
|
| 864 |
-
buffer.
|
| 865 |
|
| 866 |
##### `basic_iostream` constructors <a id="iostream.cons">[[iostream.cons]]</a>
|
| 867 |
|
| 868 |
``` cpp
|
| 869 |
explicit basic_iostream(basic_streambuf<charT, traits>* sb);
|
| 870 |
```
|
| 871 |
|
| 872 |
-
*Effects:* Constructs an object of class `basic_iostream`,
|
| 873 |
-
|
| 874 |
`basic_istream<charT, traits>(sb)` ([[istream]]) and
|
| 875 |
-
`basic_ostream<charT,traits>(sb)`
|
| 876 |
|
| 877 |
-
`rdbuf()==sb` and `gcount()==0`.
|
| 878 |
|
| 879 |
``` cpp
|
| 880 |
basic_iostream(basic_iostream&& rhs);
|
| 881 |
```
|
| 882 |
|
|
@@ -897,25 +900,13 @@ virtual ~basic_iostream();
|
|
| 897 |
|
| 898 |
``` cpp
|
| 899 |
basic_iostream& operator=(basic_iostream&& rhs);
|
| 900 |
```
|
| 901 |
|
| 902 |
-
*Effects:* `swap(rhs)`.
|
| 903 |
|
| 904 |
``` cpp
|
| 905 |
void swap(basic_iostream& rhs);
|
| 906 |
```
|
| 907 |
|
| 908 |
*Effects:* Calls `basic_istream<charT, traits>::swap(rhs)`.
|
| 909 |
|
| 910 |
-
#### Rvalue stream extraction <a id="istream.rvalue">[[istream.rvalue]]</a>
|
| 911 |
-
|
| 912 |
-
``` cpp
|
| 913 |
-
template <class charT, class traits, class T>
|
| 914 |
-
basic_istream<charT, traits>&
|
| 915 |
-
operator>>(basic_istream<charT, traits>&& is, T& x);
|
| 916 |
-
```
|
| 917 |
-
|
| 918 |
-
*Effects:* `is >>x`
|
| 919 |
-
|
| 920 |
-
*Returns:* `is`
|
| 921 |
-
|
|
|
|
| 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>&));
|
| 31 |
+
basic_istream<charT, traits>&
|
| 32 |
+
operator>>(basic_ios<charT, traits>& (*pf)(basic_ios<charT, traits>&));
|
| 33 |
+
basic_istream<charT, traits>&
|
| 34 |
+
operator>>(ios_base& (*pf)(ios_base&));
|
| 35 |
|
| 36 |
basic_istream<charT, traits>& operator>>(bool& n);
|
| 37 |
basic_istream<charT, traits>& operator>>(short& n);
|
| 38 |
basic_istream<charT, traits>& operator>>(unsigned short& n);
|
| 39 |
basic_istream<charT, traits>& operator>>(int& n);
|
|
|
|
| 45 |
basic_istream<charT, traits>& operator>>(float& f);
|
| 46 |
basic_istream<charT, traits>& operator>>(double& f);
|
| 47 |
basic_istream<charT, traits>& operator>>(long double& f);
|
| 48 |
|
| 49 |
basic_istream<charT, traits>& operator>>(void*& p);
|
| 50 |
+
basic_istream<charT, traits>& operator>>(basic_streambuf<char_type, traits>* sb);
|
|
|
|
| 51 |
|
| 52 |
+
// [istream.unformatted], unformatted input
|
| 53 |
streamsize gcount() const;
|
| 54 |
int_type get();
|
| 55 |
basic_istream<charT, traits>& get(char_type& c);
|
| 56 |
basic_istream<charT, traits>& get(char_type* s, streamsize n);
|
| 57 |
+
basic_istream<charT, traits>& get(char_type* s, streamsize n, char_type delim);
|
|
|
|
| 58 |
basic_istream<charT, traits>& get(basic_streambuf<char_type, traits>& sb);
|
| 59 |
+
basic_istream<charT, traits>& get(basic_streambuf<char_type, traits>& sb, char_type delim);
|
|
|
|
| 60 |
|
| 61 |
basic_istream<charT, traits>& getline(char_type* s, streamsize n);
|
| 62 |
+
basic_istream<charT, traits>& getline(char_type* s, streamsize n, char_type delim);
|
|
|
|
| 63 |
|
| 64 |
+
basic_istream<charT, traits>& ignore(streamsize n = 1, int_type delim = traits::eof());
|
|
|
|
| 65 |
int_type peek();
|
| 66 |
basic_istream<charT, traits>& read (char_type* s, streamsize n);
|
| 67 |
streamsize readsome(char_type* s, streamsize n);
|
| 68 |
|
| 69 |
basic_istream<charT, traits>& putback(char_type c);
|
|
|
|
| 73 |
pos_type tellg();
|
| 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& rhs) = delete;
|
| 80 |
basic_istream(basic_istream&& rhs);
|
| 81 |
|
| 82 |
+
// [istream.assign], assign and swap
|
| 83 |
basic_istream& operator=(const basic_istream& rhs) = delete;
|
| 84 |
basic_istream& operator=(basic_istream&& rhs);
|
| 85 |
void swap(basic_istream& rhs);
|
| 86 |
};
|
| 87 |
|
| 88 |
+
// [istream.extractors], character extraction templates
|
| 89 |
template<class charT, class traits>
|
| 90 |
+
basic_istream<charT, traits>& operator>>(basic_istream<charT, traits>&, charT&);
|
|
|
|
| 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
|
| 107 |
+
controlled by a stream buffer.
|
| 108 |
|
| 109 |
Two groups of member function signatures share common properties: the
|
| 110 |
*formatted input functions* (or *extractors*) and the *unformatted input
|
| 111 |
functions.* Both groups of input functions are described as if they
|
| 112 |
obtain (or *extract*) input *characters* by calling `rdbuf()->sbumpc()`
|
|
|
|
| 128 |
|
| 129 |
``` cpp
|
| 130 |
explicit basic_istream(basic_streambuf<charT, traits>* sb);
|
| 131 |
```
|
| 132 |
|
| 133 |
+
*Effects:* Constructs an object of class `basic_istream`, initializing
|
| 134 |
+
the base class subobject with
|
| 135 |
`basic_ios::init(sb)` ([[basic.ios.cons]]).
|
| 136 |
|
| 137 |
+
*Postconditions:* `gcount() == 0`.
|
| 138 |
|
| 139 |
``` cpp
|
| 140 |
basic_istream(basic_istream&& rhs);
|
| 141 |
```
|
| 142 |
|
|
|
|
| 157 |
|
| 158 |
``` cpp
|
| 159 |
basic_istream& operator=(basic_istream&& rhs);
|
| 160 |
```
|
| 161 |
|
| 162 |
+
*Effects:* As if by `swap(rhs)`.
|
| 163 |
|
| 164 |
*Returns:* `*this`.
|
| 165 |
|
| 166 |
``` cpp
|
| 167 |
void swap(basic_istream& rhs);
|
|
|
|
| 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_; }
|
|
|
|
| 201 |
to synchronize the output sequence with any associated external C
|
| 202 |
stream. Except that this call can be suppressed if the put area of
|
| 203 |
`is.tie()` is empty. Further an implementation is allowed to defer the
|
| 204 |
call to `flush` until a call of `is.rdbuf()->underflow()` occurs. If no
|
| 205 |
such call occurs before the `sentry` object is destroyed, the call to
|
| 206 |
+
`flush` may be eliminated entirely.[^18] If `noskipws` is zero and
|
| 207 |
`is.flags() & ios_base::skipws` is nonzero, the function extracts and
|
| 208 |
discards each character as long as the next available input character
|
| 209 |
`c` is a whitespace character. If `is.rdbuf()->sbumpc()` or
|
| 210 |
`is.rdbuf()->sgetc()` returns `traits::eof()`, the function calls
|
| 211 |
`setstate(failbit | eofbit)` (which may throw `ios_base::failure`).
|
| 212 |
|
| 213 |
*Remarks:* The constructor
|
| 214 |
+
|
| 215 |
+
``` cpp
|
| 216 |
+
explicit sentry(basic_istream<charT, traits>& is, bool noskipws = false)
|
| 217 |
+
```
|
| 218 |
+
|
| 219 |
uses the currently imbued locale in `is`, to determine whether the next
|
| 220 |
input character is whitespace or not.
|
| 221 |
|
| 222 |
To decide if the character `c` is a whitespace character, the
|
| 223 |
constructor performs as if it executes the following code fragment:
|
|
|
|
| 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` ([[iostate.flags]]))[^19]
|
| 235 |
|
| 236 |
``` cpp
|
| 237 |
~sentry();
|
| 238 |
```
|
| 239 |
|
|
|
|
| 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 `ios::badbit` is turned on[^20] in
|
| 257 |
`*this`’s error state. If `(exceptions()&badbit) != 0` then the
|
| 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 |
|
|
|
|
| 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 |
|
| 285 |
``` cpp
|
| 286 |
+
using numget = num_get<charT, istreambuf_iterator<charT, traits>>;
|
| 287 |
iostate err = iostate::goodbit;
|
| 288 |
use_facet<numget>(loc).get(*this, 0, *this, err, val);
|
| 289 |
setstate(err);
|
| 290 |
```
|
| 291 |
|
| 292 |
In the above fragment, `loc` stands for the private member of the
|
| 293 |
+
`basic_ios` class.
|
| 294 |
+
|
| 295 |
+
[*Note 1*: The first argument provides an object of the
|
| 296 |
`istreambuf_iterator` class which is an iterator pointed to an input
|
| 297 |
+
stream. It bypasses istreams and uses streambufs
|
| 298 |
+
directly. — *end note*]
|
| 299 |
+
|
| 300 |
+
Class `locale` relies on this type as its interface to `istream`, so
|
| 301 |
+
that it does not need to depend directly on `istream`.
|
| 302 |
|
| 303 |
``` cpp
|
| 304 |
operator>>(short& val);
|
| 305 |
```
|
| 306 |
|
| 307 |
The conversion occurs as if performed by the following code fragment
|
| 308 |
(using the same notation as for the preceding code fragment):
|
| 309 |
|
| 310 |
``` cpp
|
| 311 |
+
using numget = num_get<charT, istreambuf_iterator<charT, traits>>;
|
| 312 |
iostate err = ios_base::goodbit;
|
| 313 |
long lval;
|
| 314 |
use_facet<numget>(loc).get(*this, 0, *this, err, lval);
|
| 315 |
if (lval < numeric_limits<short>::min()) {
|
| 316 |
err |= ios_base::failbit;
|
|
|
|
| 329 |
|
| 330 |
The conversion occurs as if performed by the following code fragment
|
| 331 |
(using the same notation as for the preceding code fragment):
|
| 332 |
|
| 333 |
``` cpp
|
| 334 |
+
using numget = num_get<charT, istreambuf_iterator<charT, traits>>;
|
| 335 |
iostate err = ios_base::goodbit;
|
| 336 |
long lval;
|
| 337 |
use_facet<numget>(loc).get(*this, 0, *this, err, lval);
|
| 338 |
if (lval < numeric_limits<int>::min()) {
|
| 339 |
err |= ios_base::failbit;
|
|
|
|
| 344 |
} else
|
| 345 |
val = static_cast<int>(lval);
|
| 346 |
setstate(err);
|
| 347 |
```
|
| 348 |
|
| 349 |
+
##### `basic_istream::operator>>` <a id="istream.extractors">[[istream.extractors]]</a>
|
| 350 |
|
| 351 |
``` cpp
|
| 352 |
+
basic_istream<charT, traits>&
|
| 353 |
+
operator>>(basic_istream<charT, traits>& (*pf)(basic_istream<charT, traits>&));
|
| 354 |
```
|
| 355 |
|
| 356 |
*Effects:* None. This extractor does not behave as a formatted input
|
| 357 |
+
function (as described in [[istream.formatted.reqmts]]).
|
| 358 |
|
| 359 |
+
*Returns:* `pf(*this)`.[^21]
|
| 360 |
|
| 361 |
``` cpp
|
| 362 |
+
basic_istream<charT, traits>&
|
| 363 |
+
operator>>(basic_ios<charT, traits>& (*pf)(basic_ios<charT, traits>&));
|
| 364 |
```
|
| 365 |
|
| 366 |
*Effects:* Calls `pf(*this)`. This extractor does not behave as a
|
| 367 |
formatted input function (as described
|
| 368 |
in [[istream.formatted.reqmts]]).
|
| 369 |
|
| 370 |
*Returns:* `*this`.
|
| 371 |
|
| 372 |
``` cpp
|
| 373 |
+
basic_istream<charT, traits>& operator>>(ios_base& (*pf)(ios_base&));
|
|
|
|
| 374 |
```
|
| 375 |
|
| 376 |
+
*Effects:* Calls `pf(*this)`.[^22] This extractor does not behave as a
|
| 377 |
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* s);
|
|
|
|
| 385 |
template<class traits>
|
| 386 |
+
basic_istream<char, traits>& operator>>(basic_istream<char, traits>& in, unsigned char* s);
|
|
|
|
| 387 |
template<class traits>
|
| 388 |
+
basic_istream<char, traits>& operator>>(basic_istream<char, traits>& in, signed char* s);
|
|
|
|
| 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
|
|
|
|
| 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;
|
| 404 |
+
- letting `ct` be `use_facet<ctype<charT>>(in.getloc())`,
|
| 405 |
+
`ct.is(ct.space, c)` is `true`.
|
| 406 |
|
| 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 |
|
|
|
|
| 413 |
|
| 414 |
*Returns:* `in`.
|
| 415 |
|
| 416 |
``` cpp
|
| 417 |
template<class charT, class traits>
|
| 418 |
+
basic_istream<charT, traits>& operator>>(basic_istream<charT, traits>& in, charT& c);
|
|
|
|
| 419 |
template<class traits>
|
| 420 |
+
basic_istream<char, traits>& operator>>(basic_istream<char, traits>& in, unsigned char& c);
|
|
|
|
| 421 |
template<class traits>
|
| 422 |
+
basic_istream<char, traits>& operator>>(basic_istream<char, traits>& in, signed char& c);
|
|
|
|
| 423 |
```
|
| 424 |
|
| 425 |
*Effects:* Behaves like a formatted input member (as described
|
| 426 |
in [[istream.formatted.reqmts]]) of `in`. After a `sentry` object is
|
| 427 |
constructed a character is extracted from `in`, if one is available, and
|
| 428 |
stored in `c`. Otherwise, the function calls `in.setstate(failbit)`.
|
| 429 |
|
| 430 |
*Returns:* `in`.
|
| 431 |
|
| 432 |
``` cpp
|
| 433 |
+
basic_istream<charT, traits>& operator>>(basic_streambuf<charT, traits>* sb);
|
|
|
|
| 434 |
```
|
| 435 |
|
| 436 |
+
*Effects:* Behaves as an unformatted input function
|
| 437 |
+
([[istream.unformatted]]). If `sb` is null, calls `setstate(failbit)`,
|
| 438 |
+
which may throw `ios_base::failure` ([[iostate.flags]]). After a sentry
|
| 439 |
+
object is constructed, extracts characters from `*this` and inserts them
|
| 440 |
+
in the output sequence controlled by `sb`. Characters are extracted and
|
|
|
|
| 441 |
inserted until any of the following occurs:
|
| 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);
|
|
|
|
| 459 |
Each unformatted input function begins execution by constructing an
|
| 460 |
object of class `sentry` with the default argument `noskipws` (second)
|
| 461 |
argument `true`. If the `sentry` object returns `true`, when converted
|
| 462 |
to a value of type `bool`, the function endeavors to obtain the
|
| 463 |
requested input. Otherwise, if the sentry constructor exits by throwing
|
| 464 |
+
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 `ios::badbit` is turned on[^23] in `*this`’s error
|
| 471 |
+
state. (Exceptions thrown from `basic_ios<>::clear()` are not caught or
|
| 472 |
rethrown.) If `(exceptions()&badbit) != 0` then the exception is
|
| 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.
|
|
|
|
| 478 |
``` cpp
|
| 479 |
streamsize gcount() const;
|
| 480 |
```
|
| 481 |
|
| 482 |
*Effects:* None. This member function does not behave as an unformatted
|
| 483 |
+
input function (as described above).
|
| 484 |
|
| 485 |
*Returns:* The number of characters extracted by the last unformatted
|
| 486 |
input member function called for the object.
|
| 487 |
|
| 488 |
``` cpp
|
| 489 |
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` ([[iostate.flags]]),
|
|
|
|
| 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 |
+
`ios_base::failure` ([[iostate.flags]])).
|
| 508 |
|
| 509 |
*Returns:* `*this`.
|
| 510 |
|
| 511 |
``` cpp
|
| 512 |
+
basic_istream<charT, traits>& get(char_type* s, streamsize n, char_type delim);
|
|
|
|
| 513 |
```
|
| 514 |
|
| 515 |
*Effects:* Behaves as an unformatted input function (as described
|
| 516 |
+
above). After constructing a sentry object, extracts characters and
|
| 517 |
+
stores them into successive locations of an array whose first element is
|
| 518 |
+
designated by `s`.[^25] Characters are extracted and stored until any of
|
| 519 |
+
the following occurs:
|
| 520 |
|
| 521 |
- `n` is less than one or `n - 1` characters are stored;
|
| 522 |
- end-of-file occurs on the input sequence (in which case the function
|
| 523 |
calls `setstate(eofbit)`);
|
| 524 |
- `traits::eq(c, delim)` for the next available input character `c` (in
|
|
|
|
| 533 |
|
| 534 |
``` cpp
|
| 535 |
basic_istream<charT, traits>& get(char_type* s, streamsize n);
|
| 536 |
```
|
| 537 |
|
| 538 |
+
*Effects:* Calls `get(s, n, widen(’\n’))`.
|
| 539 |
|
| 540 |
*Returns:* Value returned by the call.
|
| 541 |
|
| 542 |
``` cpp
|
| 543 |
+
basic_istream<charT, traits>& get(basic_streambuf<char_type, traits>& sb, char_type delim);
|
|
|
|
| 544 |
```
|
| 545 |
|
| 546 |
*Effects:* Behaves as an unformatted input function (as described
|
| 547 |
+
above). After constructing a sentry object, extracts characters and
|
| 548 |
+
inserts them in the output sequence controlled by `sb`. Characters are
|
| 549 |
+
extracted and inserted until any of the following occurs:
|
|
|
|
| 550 |
|
| 551 |
- end-of-file occurs on the input sequence;
|
| 552 |
- inserting in the output sequence fails (in which case the character to
|
| 553 |
be inserted is not extracted);
|
| 554 |
- `traits::eq(c, delim)` for the next available input character `c` (in
|
|
|
|
| 563 |
|
| 564 |
``` cpp
|
| 565 |
basic_istream<charT, traits>& get(basic_streambuf<char_type, traits>& sb);
|
| 566 |
```
|
| 567 |
|
| 568 |
+
*Effects:* Calls `get(sb, widen(’\n’))`.
|
| 569 |
|
| 570 |
*Returns:* Value returned by the call.
|
| 571 |
|
| 572 |
``` cpp
|
| 573 |
+
basic_istream<charT, traits>& getline(char_type* s, streamsize n, char_type delim);
|
|
|
|
| 574 |
```
|
| 575 |
|
| 576 |
*Effects:* Behaves as an unformatted input function (as described
|
| 577 |
+
above). After constructing a sentry object, extracts characters and
|
| 578 |
+
stores them into successive locations of an array whose first element is
|
| 579 |
+
designated by `s`.[^26] Characters are extracted and stored until one of
|
| 580 |
+
the following occurs:
|
| 581 |
|
| 582 |
1. end-of-file occurs on the input sequence (in which case the function
|
| 583 |
calls `setstate(eofbit)`);
|
| 584 |
2. `traits::eq(c, delim)` for the next available input character `c`
|
| 585 |
(in which case the input character is extracted but not
|
| 586 |
+
stored);[^27]
|
| 587 |
3. `n` is less than one or `n - 1` characters are stored (in which case
|
| 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` ([[iostate.flags]])).[^29]
|
| 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 |
|
| 599 |
*Returns:* `*this`.
|
| 600 |
|
| 601 |
+
[*Example 1*:
|
| 602 |
+
|
| 603 |
``` cpp
|
| 604 |
#include <iostream>
|
| 605 |
|
| 606 |
int main() {
|
| 607 |
using namespace std;
|
|
|
|
| 623 |
cout << " (" << count << " chars): " << buffer << endl;
|
| 624 |
}
|
| 625 |
}
|
| 626 |
```
|
| 627 |
|
| 628 |
+
— *end example*]
|
| 629 |
+
|
| 630 |
``` cpp
|
| 631 |
basic_istream<charT, traits>& getline(char_type* s, streamsize n);
|
| 632 |
```
|
| 633 |
|
| 634 |
*Returns:* `getline(s, n, widen(’\n’))`
|
| 635 |
|
| 636 |
``` cpp
|
| 637 |
+
basic_istream<charT, traits>& ignore(streamsize n = 1, int_type delim = traits::eof());
|
|
|
|
| 638 |
```
|
| 639 |
|
| 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()` ([[numeric.limits]]) and `n`
|
| 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 |
`ios_base::failure` ([[iostate.flags]]));
|
| 650 |
- `traits::eq_int_type(traits::to_int_type(c), delim)` for the next
|
|
|
|
| 658 |
``` cpp
|
| 659 |
int_type peek();
|
| 660 |
```
|
| 661 |
|
| 662 |
*Effects:* Behaves as an unformatted input function (as described
|
| 663 |
+
above). After constructing a sentry object, reads but does not extract
|
| 664 |
+
the current input character.
|
| 665 |
|
| 666 |
*Returns:* `traits::eof()` if `good()` is `false`. Otherwise, returns
|
| 667 |
`rdbuf()->sgetc()`.
|
| 668 |
|
| 669 |
``` cpp
|
| 670 |
basic_istream<charT, traits>& read(char_type* s, streamsize n);
|
| 671 |
```
|
| 672 |
|
| 673 |
*Effects:* Behaves as an unformatted input function (as described
|
| 674 |
+
above). After constructing a sentry object, if `!good()` calls
|
| 675 |
+
`setstate(failbit)` which may throw an exception, and return. Otherwise
|
| 676 |
+
extracts characters and stores them into successive locations of an
|
| 677 |
+
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` ([[iostate.flags]])).
|
|
|
|
| 687 |
``` cpp
|
| 688 |
streamsize readsome(char_type* s, streamsize n);
|
| 689 |
```
|
| 690 |
|
| 691 |
*Effects:* Behaves as an unformatted input function (as described
|
| 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` ([[iostate.flags]])), and extracts no characters;
|
|
|
|
| 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.
|
|
|
|
| 704 |
``` cpp
|
| 705 |
basic_istream<charT, traits>& putback(char_type c);
|
| 706 |
```
|
| 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` ([[iostate.flags]])).
|
| 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`.
|
| 720 |
|
| 721 |
``` cpp
|
| 722 |
basic_istream<charT, traits>& unget();
|
| 723 |
```
|
| 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` ([[iostate.flags]])).
|
| 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`.
|
| 737 |
|
| 738 |
``` cpp
|
| 739 |
int sync();
|
| 740 |
```
|
| 741 |
|
| 742 |
*Effects:* Behaves as an unformatted input function (as described
|
| 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` ([[iostate.flags]]), and returns `-1`. Otherwise,
|
| 749 |
returns zero.
|
| 750 |
|
| 751 |
``` cpp
|
| 752 |
pos_type tellg();
|
| 753 |
```
|
| 754 |
|
| 755 |
*Effects:* Behaves as an unformatted input function (as described
|
| 756 |
+
above), except that it does not count the number of characters extracted
|
| 757 |
+
and does not affect the value returned by subsequent calls to
|
| 758 |
+
`gcount()`.
|
| 759 |
|
| 760 |
*Returns:* After constructing a sentry object, if `fail() != false`,
|
| 761 |
returns `pos_type(-1)` to indicate failure. Otherwise, returns
|
| 762 |
`rdbuf()->pubseekoff(0, cur, in)`.
|
| 763 |
|
| 764 |
``` cpp
|
| 765 |
basic_istream<charT, traits>& seekg(pos_type pos);
|
| 766 |
```
|
| 767 |
|
| 768 |
*Effects:* Behaves as an unformatted input function (as described
|
| 769 |
+
above), except that the function first clears `eofbit`, it does not
|
| 770 |
+
count the number of characters extracted, and it does not affect the
|
| 771 |
+
value returned by subsequent calls to `gcount()`. After constructing a
|
| 772 |
+
sentry object, if `fail() != true`, executes
|
| 773 |
+
`rdbuf()->pubseekpos(pos, ios_base::in)`. In case of failure, the
|
| 774 |
+
function calls `setstate(failbit)` (which may throw
|
| 775 |
`ios_base::failure`).
|
| 776 |
|
| 777 |
*Returns:* `*this`.
|
| 778 |
|
| 779 |
``` cpp
|
| 780 |
basic_istream<charT, traits>& seekg(off_type off, ios_base::seekdir dir);
|
| 781 |
```
|
| 782 |
|
| 783 |
*Effects:* Behaves as an unformatted input function (as described
|
| 784 |
+
above), except that the function first clears `eofbit`, does not count
|
| 785 |
+
the number of characters extracted, and does not affect the value
|
| 786 |
returned by subsequent calls to `gcount()`. After constructing a sentry
|
| 787 |
object, if `fail() != true`, executes
|
| 788 |
`rdbuf()->pubseekoff(off, dir, ios_base::in)`. In case of failure, the
|
| 789 |
function calls `setstate(failbit)` (which may throw
|
| 790 |
`ios_base::failure`).
|
|
|
|
| 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 function
|
| 802 |
+
([[istream.unformatted]]), except that it does not count the number of
|
| 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` ([[istream::sentry]]). If `ws` stops extracting
|
| 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 <class charT, class traits, class T>
|
| 818 |
+
basic_istream<charT, traits>& operator>>(basic_istream<charT, traits>&& is, T&& x);
|
| 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>>
|
| 836 |
+
class basic_iostream
|
| 837 |
+
: public basic_istream<charT, traits>,
|
| 838 |
public basic_ostream<charT, traits> {
|
| 839 |
public:
|
| 840 |
+
using char_type = charT;
|
| 841 |
+
using int_type = typename traits::int_type;
|
| 842 |
+
using pos_type = typename traits::pos_type;
|
| 843 |
+
using off_type = typename traits::off_type;
|
| 844 |
+
using traits_type = traits;
|
|
|
|
| 845 |
|
| 846 |
+
// [iostream.cons], constructor
|
| 847 |
explicit basic_iostream(basic_streambuf<charT, traits>* sb);
|
| 848 |
+
|
| 849 |
+
// [iostream.dest], destructor
|
| 850 |
virtual ~basic_iostream();
|
| 851 |
|
| 852 |
protected:
|
| 853 |
+
// [iostream.cons], constructor
|
| 854 |
basic_iostream(const basic_iostream& rhs) = delete;
|
| 855 |
basic_iostream(basic_iostream&& rhs);
|
| 856 |
|
| 857 |
+
// [iostream.assign], assign and swap
|
| 858 |
basic_iostream& operator=(const basic_iostream& rhs) = delete;
|
| 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 |
##### `basic_iostream` constructors <a id="iostream.cons">[[iostream.cons]]</a>
|
| 870 |
|
| 871 |
``` cpp
|
| 872 |
explicit basic_iostream(basic_streambuf<charT, traits>* sb);
|
| 873 |
```
|
| 874 |
|
| 875 |
+
*Effects:* Constructs an object of class `basic_iostream`, initializing
|
| 876 |
+
the base class subobjects with
|
| 877 |
`basic_istream<charT, traits>(sb)` ([[istream]]) and
|
| 878 |
+
`basic_ostream<charT, traits>(sb)` ([[ostream]]).
|
| 879 |
|
| 880 |
+
*Postconditions:* `rdbuf() == sb` and `gcount() == 0`.
|
| 881 |
|
| 882 |
``` cpp
|
| 883 |
basic_iostream(basic_iostream&& rhs);
|
| 884 |
```
|
| 885 |
|
|
|
|
| 900 |
|
| 901 |
``` cpp
|
| 902 |
basic_iostream& operator=(basic_iostream&& rhs);
|
| 903 |
```
|
| 904 |
|
| 905 |
+
*Effects:* As if by `swap(rhs)`.
|
| 906 |
|
| 907 |
``` cpp
|
| 908 |
void swap(basic_iostream& rhs);
|
| 909 |
```
|
| 910 |
|
| 911 |
*Effects:* Calls `basic_istream<charT, traits>::swap(rhs)`.
|
| 912 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|