From Jason Turner

[input.streams]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmpoc27z615/{from.md → to.md} +264 -209
tmp/tmpoc27z615/{from.md → to.md} RENAMED
@@ -1,13 +1,22 @@
1
  ### Input streams <a id="input.streams">[[input.streams]]</a>
2
 
3
- The header `<istream>` defines two types and a function signature that
4
- control input from a stream buffer along with a function template that
5
- extracts from stream rvalues.
 
 
6
 
7
  #### Class template `basic_istream` <a id="istream">[[istream]]</a>
8
 
 
 
 
 
 
 
 
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:
@@ -24,64 +33,62 @@ namespace std {
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);
40
- basic_istream<charT, traits>& operator>>(unsigned int& n);
41
- basic_istream<charT, traits>& operator>>(long& n);
42
- basic_istream<charT, traits>& operator>>(unsigned long& n);
43
- basic_istream<charT, traits>& operator>>(long long& n);
44
- basic_istream<charT, traits>& operator>>(unsigned long long& 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);
70
- basic_istream<charT, traits>& unget();
71
  int sync();
72
 
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&) = 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
 
@@ -110,22 +117,10 @@ 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()`
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
  ```
@@ -168,15 +163,16 @@ 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_; }
180
  sentry(const sentry&) = delete;
181
  sentry& operator=(const sentry&) = delete;
182
  };
@@ -185,32 +181,34 @@ namespace std {
185
 
186
  The class `sentry` defines a class that is responsible for doing
187
  exception safe prefix and suffix operations.
188
 
189
  ``` cpp
190
- explicit sentry(basic_istream<charT, traits>& is, bool noskipws = false);
191
  ```
192
 
193
  *Effects:* If `is.good()` is `false`, calls `is.setstate(failbit)`.
194
  Otherwise, prepares for formatted or unformatted input. First, if
195
  `is.tie()` is not a null pointer, the function calls `is.tie()->flush()`
196
  to synchronize the output sequence with any associated external C
197
  stream. Except that this call can be suppressed if the put area of
198
  `is.tie()` is empty. Further an implementation is allowed to defer the
199
  call to `flush` until a call of `is.rdbuf()->underflow()` occurs. If no
200
  such call occurs before the `sentry` object is destroyed, the call to
201
- `flush` may be eliminated entirely.[^18] If `noskipws` is zero and
202
- `is.flags() & ios_base::skipws` is nonzero, the function extracts and
203
- discards each character as long as the next available input character
204
- `c` is a whitespace character. If `is.rdbuf()->sbumpc()` or
205
- `is.rdbuf()->sgetc()` returns `traits::eof()`, the function calls
206
- `setstate(failbit | eofbit)` (which may throw `ios_base::failure`).
 
 
207
 
208
  *Remarks:* The constructor
209
 
210
  ``` cpp
211
- explicit sentry(basic_istream<charT, traits>& is, bool noskipws = false)
212
  ```
213
 
214
  uses the currently imbued locale in `is`, to determine whether the next
215
  input character is whitespace or not.
216
 
@@ -243,47 +241,56 @@ explicit operator bool() const;
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
 
259
  ``` cpp
260
- operator>>(unsigned short& val);
261
- operator>>(unsigned int& val);
262
- operator>>(long& val);
263
- operator>>(unsigned long& val);
264
- operator>>(long long& val);
265
- operator>>(unsigned long long& val);
266
- operator>>(float& val);
267
- operator>>(double& val);
268
- operator>>(long double& val);
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
 
280
  ``` cpp
281
  using numget = num_get<charT, istreambuf_iterator<charT, traits>>;
282
- iostate err = iostate::goodbit;
283
- use_facet<numget>(loc).get(*this, 0, *this, err, val);
284
- setstate(err);
285
  ```
286
 
287
  In the above fragment, `loc` stands for the private member of the
288
  `basic_ios` class.
289
 
@@ -294,85 +301,123 @@ directly. — *end note*]
294
 
295
  Class `locale` relies on this type as its interface to `istream`, so
296
  that it does not need to depend directly on `istream`.
297
 
298
  ``` cpp
299
- operator>>(short& val);
300
  ```
301
 
302
  The conversion occurs as if performed by the following code fragment
303
  (using the same notation as for the preceding code fragment):
304
 
305
  ``` cpp
306
  using numget = num_get<charT, istreambuf_iterator<charT, traits>>;
307
- iostate err = ios_base::goodbit;
308
  long lval;
309
- use_facet<numget>(loc).get(*this, 0, *this, err, lval);
310
  if (lval < numeric_limits<short>::min()) {
311
- err |= ios_base::failbit;
312
  val = numeric_limits<short>::min();
313
  } else if (numeric_limits<short>::max() < lval) {
314
- err |= ios_base::failbit;
315
  val = numeric_limits<short>::max();
316
  } else
317
  val = static_cast<short>(lval);
318
- setstate(err);
319
  ```
320
 
321
  ``` cpp
322
- operator>>(int& val);
323
  ```
324
 
325
  The conversion occurs as if performed by the following code fragment
326
  (using the same notation as for the preceding code fragment):
327
 
328
  ``` cpp
329
  using numget = num_get<charT, istreambuf_iterator<charT, traits>>;
330
- iostate err = ios_base::goodbit;
331
  long lval;
332
- use_facet<numget>(loc).get(*this, 0, *this, err, lval);
333
  if (lval < numeric_limits<int>::min()) {
334
- err |= ios_base::failbit;
335
  val = numeric_limits<int>::min();
336
  } else if (numeric_limits<int>::max() < lval) {
337
- err |= ios_base::failbit;
338
  val = numeric_limits<int>::max();
339
  } else
340
  val = static_cast<int>(lval);
341
- setstate(err);
342
  ```
343
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
344
  ##### `basic_istream::operator>>` <a id="istream.extractors">[[istream.extractors]]</a>
345
 
346
  ``` cpp
347
- basic_istream<charT, traits>&
348
- operator>>(basic_istream<charT, traits>& (*pf)(basic_istream<charT, traits>&));
349
  ```
350
 
351
  *Effects:* None. This extractor does not behave as a formatted input
352
  function (as described in  [[istream.formatted.reqmts]]).
353
 
354
- *Returns:* `pf(*this)`.[^21]
355
 
356
  ``` cpp
357
- basic_istream<charT, traits>&
358
- operator>>(basic_ios<charT, traits>& (*pf)(basic_ios<charT, traits>&));
359
  ```
360
 
361
  *Effects:* Calls `pf(*this)`. This extractor does not behave as a
362
  formatted input function (as described
363
  in  [[istream.formatted.reqmts]]).
364
 
365
  *Returns:* `*this`.
366
 
367
  ``` cpp
368
- basic_istream<charT, traits>& operator>>(ios_base& (*pf)(ios_base&));
369
  ```
370
 
371
- *Effects:* Calls `pf(*this)`.[^22] This extractor does not behave as a
372
- formatted input function (as described
373
- in  [[istream.formatted.reqmts]]).
 
374
 
375
  *Returns:* `*this`.
376
 
377
  ``` cpp
378
  template<class charT, class traits, size_t N>
@@ -398,12 +443,12 @@ Characters are extracted and stored until any of the following occurs:
398
 
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>
@@ -413,132 +458,138 @@ template<class traits>
413
  template<class traits>
414
  basic_istream<char, traits>& operator>>(basic_istream<char, traits>& in, signed char& c);
415
  ```
416
 
417
  *Effects:* Behaves like a formatted input member (as described
418
- in  [[istream.formatted.reqmts]]) of `in`. After a `sentry` object is
419
- constructed a character is extracted from `in`, if one is available, and
420
- stored in `c`. Otherwise, the function calls `in.setstate(failbit)`.
 
421
 
422
  *Returns:* `in`.
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
 
451
  Each unformatted input function begins execution by constructing an
452
- object of class `sentry` with the default argument `noskipws` (second)
453
- argument `true`. If the `sentry` object returns `true`, when converted
454
- to a value of type `bool`, the function endeavors to obtain the
455
- requested input. Otherwise, if the sentry constructor exits by throwing
456
- an exception or if the sentry object returns `false`, when converted to
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
471
  streamsize gcount() const;
472
  ```
473
 
474
  *Effects:* None. This member function does not behave as an unformatted
475
  input function (as described above).
476
 
477
  *Returns:* The number of characters extracted by the last unformatted
478
- input member function called for the object.
 
479
 
480
  ``` cpp
481
  int_type get();
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);
505
  ```
506
 
507
  *Effects:* Behaves as an unformatted input function (as described
508
- above). After constructing a sentry object, extracts characters and
509
  stores them into successive locations of an array whose first element is
510
- designated by `s`.[^25] Characters are extracted and stored until any of
511
- the following occurs:
 
512
 
513
  - `n` is less than one or `n - 1` characters are stored;
514
- - end-of-file occurs on the input sequence (in which case the function
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);
528
  ```
529
 
530
  *Effects:* Calls `get(s, n, widen(’\n’))`.
531
 
532
  *Returns:* Value returned by the call.
533
 
534
  ``` cpp
535
- basic_istream<charT, traits>& get(basic_streambuf<char_type, traits>& sb, char_type delim);
536
  ```
537
 
538
  *Effects:* Behaves as an unformatted input function (as described
539
- above). After constructing a sentry object, extracts characters and
540
  inserts them in the output sequence controlled by `sb`. Characters are
541
  extracted and inserted until any of the following occurs:
542
 
543
  - end-of-file occurs on the input sequence;
544
  - inserting in the output sequence fails (in which case the character to
@@ -546,45 +597,45 @@ extracted and inserted until any of the following occurs:
546
  - `traits::eq(c, delim)` for the next available input character `c` (in
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);
558
  ```
559
 
560
  *Effects:* Calls `get(sb, widen(’\n’))`.
561
 
562
  *Returns:* Value returned by the call.
563
 
564
  ``` cpp
565
- basic_istream<charT, traits>& getline(char_type* s, streamsize n, char_type delim);
566
  ```
567
 
568
  *Effects:* Behaves as an unformatted input function (as described
569
- above). After constructing a sentry object, extracts characters and
570
  stores them into successive locations of an array whose first element is
571
- designated by `s`.[^26] Characters are extracted and stored until one of
572
- the following occurs:
573
 
574
- 1. end-of-file occurs on the input sequence (in which case the function
575
- calls `setstate(eofbit)`);
 
576
  2. `traits::eq(c, delim)` for the next available input character `c`
577
  (in which case the input character is extracted but not
578
- stored);[^27]
579
  3. `n` is less than one or `n - 1` characters are stored (in which case
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
 
@@ -618,21 +669,21 @@ int main() {
618
  ```
619
 
620
  — *end example*]
621
 
622
  ``` cpp
623
- basic_istream<charT, traits>& getline(char_type* s, streamsize n);
624
  ```
625
 
626
  *Returns:* `getline(s, n, widen(’\n’))`
627
 
628
  ``` cpp
629
- basic_istream<charT, traits>& ignore(streamsize n = 1, int_type delim = traits::eof());
630
  ```
631
 
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
@@ -640,36 +691,38 @@ occurs:
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())`.
647
 
648
  *Returns:* `*this`.
649
 
650
  ``` cpp
651
  int_type peek();
652
  ```
653
 
654
  *Effects:* Behaves as an unformatted input function (as described
655
- above). After constructing a sentry object, reads but does not extract
656
  the current input character.
657
 
658
  *Returns:* `traits::eof()` if `good()` is `false`. Otherwise, returns
659
  `rdbuf()->sgetc()`.
660
 
661
  ``` cpp
662
- basic_istream<charT, traits>& read(char_type* s, streamsize n);
663
  ```
664
 
665
  *Effects:* Behaves as an unformatted input function (as described
666
- above). After constructing a sentry object, if `!good()` calls
667
  `setstate(failbit)` which may throw an exception, and return. Otherwise
668
  extracts characters and stores them into successive locations of an
669
- array whose first element is designated by `s`.[^30] Characters are
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]]).
@@ -679,11 +732,11 @@ extracted and stored until either of the following occurs:
679
  ``` cpp
680
  streamsize readsome(char_type* s, streamsize n);
681
  ```
682
 
683
  *Effects:* Behaves as an unformatted input function (as described
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;
@@ -692,51 +745,51 @@ array whose first element is designated by `s`. If
692
  - If `rdbuf()->in_avail() > 0`, extracts `min(rdbuf()->in_avail(), n))`.
693
 
694
  *Returns:* The number of characters extracted.
695
 
696
  ``` cpp
697
- basic_istream<charT, traits>& putback(char_type c);
698
  ```
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`.
712
-
713
- ``` cpp
714
- basic_istream<charT, traits>& unget();
715
- ```
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`.
729
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
730
  ``` cpp
731
  int sync();
732
  ```
733
 
734
  *Effects:* Behaves as an unformatted input function (as described
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
 
@@ -747,38 +800,38 @@ pos_type tellg();
747
  *Effects:* Behaves as an unformatted input function (as described
748
  above), except that it does not count the number of characters extracted
749
  and does not affect the value returned by subsequent calls to
750
  `gcount()`.
751
 
752
- *Returns:* After constructing a sentry object, if `fail() != false`,
753
  returns `pos_type(-1)` to indicate failure. Otherwise, returns
754
  `rdbuf()->pubseekoff(0, cur, in)`.
755
 
756
  ``` cpp
757
- basic_istream<charT, traits>& seekg(pos_type pos);
758
  ```
759
 
760
  *Effects:* Behaves as an unformatted input function (as described
761
  above), except that the function first clears `eofbit`, it does not
762
  count the number of characters extracted, and it does not affect the
763
  value returned by subsequent calls to `gcount()`. After constructing a
764
- sentry object, if `fail() != true`, executes
765
  `rdbuf()->pubseekpos(pos, ios_base::in)`. In case of failure, the
766
  function calls `setstate(failbit)` (which may throw
767
  `ios_base::failure`).
768
 
769
  *Returns:* `*this`.
770
 
771
  ``` cpp
772
- basic_istream<charT, traits>& seekg(off_type off, ios_base::seekdir dir);
773
  ```
774
 
775
  *Effects:* Behaves as an unformatted input function (as described
776
  above), except that the function first clears `eofbit`, does not count
777
  the number of characters extracted, and does not affect the value
778
- returned by subsequent calls to `gcount()`. After constructing a sentry
779
- object, if `fail() != true`, executes
780
  `rdbuf()->pubseekoff(off, dir, ios_base::in)`. In case of failure, the
781
  function calls `setstate(failbit)` (which may throw
782
  `ios_base::failure`).
783
 
784
  *Returns:* `*this`.
@@ -794,11 +847,11 @@ template<class charT, class traits>
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
@@ -812,22 +865,24 @@ characters because there are no more available it sets `eofbit`, but not
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>>
832
  class basic_iostream
833
  : public basic_istream<charT, traits>,
@@ -848,11 +903,11 @@ namespace std {
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
  }
@@ -877,11 +932,11 @@ explicit basic_iostream(basic_streambuf<charT, traits>* sb);
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();
 
1
  ### Input streams <a id="input.streams">[[input.streams]]</a>
2
 
3
+ #### General <a id="input.streams.general">[[input.streams.general]]</a>
4
+
5
+ The header `<istream>` defines two class templates and a function
6
+ template that control input from a stream buffer, along with a function
7
+ template that extracts from stream rvalues.
8
 
9
  #### Class template `basic_istream` <a id="istream">[[istream]]</a>
10
 
11
+ ##### General <a id="istream.general">[[istream.general]]</a>
12
+
13
+ When a function is specified with a type placeholder of
14
+ `extended-floating-point-type`, the implementation provides overloads
15
+ for all cv-unqualified extended floating-point types
16
+ [[basic.fundamental]] in lieu of `extended-floating-{point-type}`.
17
+
18
  ``` cpp
19
  namespace std {
20
  template<class charT, class traits = char_traits<charT>>
21
  class basic_istream : virtual public basic_ios<charT, traits> {
22
  public:
 
33
 
34
  // [istream.sentry], prefix/suffix
35
  class sentry;
36
 
37
  // [istream.formatted], formatted input
38
+ basic_istream& operator>>(basic_istream& (*pf)(basic_istream&));
39
+ basic_istream& operator>>(basic_ios<charT, traits>& (*pf)(basic_ios<charT, traits>&));
40
+ basic_istream& operator>>(ios_base& (*pf)(ios_base&));
 
 
 
41
 
42
+ basic_istream& operator>>(bool& n);
43
+ basic_istream& operator>>(short& n);
44
+ basic_istream& operator>>(unsigned short& n);
45
+ basic_istream& operator>>(int& n);
46
+ basic_istream& operator>>(unsigned int& n);
47
+ basic_istream& operator>>(long& n);
48
+ basic_istream& operator>>(unsigned long& n);
49
+ basic_istream& operator>>(long long& n);
50
+ basic_istream& operator>>(unsigned long long& n);
51
+ basic_istream& operator>>(float& f);
52
+ basic_istream& operator>>(double& f);
53
+ basic_istream& operator>>(long double& f);
54
+ basic_istream& operator>>(extended-floating-point-type& f);
55
 
56
+ basic_istream& operator>>(void*& p);
57
+ basic_istream& operator>>(basic_streambuf<char_type, traits>* sb);
58
 
59
  // [istream.unformatted], unformatted input
60
  streamsize gcount() const;
61
  int_type get();
62
+ basic_istream& get(char_type& c);
63
+ basic_istream& get(char_type* s, streamsize n);
64
+ basic_istream& get(char_type* s, streamsize n, char_type delim);
65
+ basic_istream& get(basic_streambuf<char_type, traits>& sb);
66
+ basic_istream& get(basic_streambuf<char_type, traits>& sb, char_type delim);
67
 
68
+ basic_istream& getline(char_type* s, streamsize n);
69
+ basic_istream& getline(char_type* s, streamsize n, char_type delim);
70
 
71
+ basic_istream& ignore(streamsize n = 1, int_type delim = traits::eof());
72
  int_type peek();
73
+ basic_istream& read (char_type* s, streamsize n);
74
  streamsize readsome(char_type* s, streamsize n);
75
 
76
+ basic_istream& putback(char_type c);
77
+ basic_istream& unget();
78
  int sync();
79
 
80
  pos_type tellg();
81
+ basic_istream& seekg(pos_type);
82
+ basic_istream& seekg(off_type, ios_base::seekdir);
83
 
84
  protected:
85
  // [istream.cons], copy/move constructor
86
  basic_istream(const basic_istream&) = delete;
87
  basic_istream(basic_istream&& rhs);
88
 
89
+ // [istream.assign], assignment and swap
90
  basic_istream& operator=(const basic_istream&) = delete;
91
  basic_istream& operator=(basic_istream&& rhs);
92
  void swap(basic_istream& rhs);
93
  };
94
 
 
117
  *formatted input functions* (or *extractors*) and the *unformatted input
118
  functions.* Both groups of input functions are described as if they
119
  obtain (or *extract*) input *characters* by calling `rdbuf()->sbumpc()`
120
  or `rdbuf()->sgetc()`. They may use other public members of `istream`.
121
 
 
 
 
 
 
 
 
 
 
 
 
 
122
  ##### Constructors <a id="istream.cons">[[istream.cons]]</a>
123
 
124
  ``` cpp
125
  explicit basic_istream(basic_streambuf<charT, traits>* sb);
126
  ```
 
163
 
164
  ##### Class `basic_istream::sentry` <a id="istream.sentry">[[istream.sentry]]</a>
165
 
166
  ``` cpp
167
  namespace std {
168
+ template<class charT, class traits>
169
  class basic_istream<charT, traits>::sentry {
170
  bool ok_; // exposition only
171
+
172
  public:
173
+ explicit sentry(basic_istream& is, bool noskipws = false);
174
  ~sentry();
175
  explicit operator bool() const { return ok_; }
176
  sentry(const sentry&) = delete;
177
  sentry& operator=(const sentry&) = delete;
178
  };
 
181
 
182
  The class `sentry` defines a class that is responsible for doing
183
  exception safe prefix and suffix operations.
184
 
185
  ``` cpp
186
+ explicit sentry(basic_istream& is, bool noskipws = false);
187
  ```
188
 
189
  *Effects:* If `is.good()` is `false`, calls `is.setstate(failbit)`.
190
  Otherwise, prepares for formatted or unformatted input. First, if
191
  `is.tie()` is not a null pointer, the function calls `is.tie()->flush()`
192
  to synchronize the output sequence with any associated external C
193
  stream. Except that this call can be suppressed if the put area of
194
  `is.tie()` is empty. Further an implementation is allowed to defer the
195
  call to `flush` until a call of `is.rdbuf()->underflow()` occurs. If no
196
  such call occurs before the `sentry` object is destroyed, the call to
197
+ `flush` may be eliminated entirely.[^18]
198
+
199
+ If `noskipws` is zero and `is.flags() & ios_base::skipws` is nonzero,
200
+ the function extracts and discards each character as long as the next
201
+ available input character `c` is a whitespace character. If
202
+ `is.rdbuf()->sbumpc()` or `is.rdbuf()->sgetc()` returns `traits::eof()`,
203
+ the function calls `setstate(failbit | eofbit)` (which may throw
204
+ `ios_base::failure`).
205
 
206
  *Remarks:* The constructor
207
 
208
  ``` cpp
209
+ explicit sentry(basic_istream& is, bool noskipws = false)
210
  ```
211
 
212
  uses the currently imbued locale in `is`, to determine whether the next
213
  input character is whitespace or not.
214
 
 
241
  #### Formatted input functions <a id="istream.formatted">[[istream.formatted]]</a>
242
 
243
  ##### Common requirements <a id="istream.formatted.reqmts">[[istream.formatted.reqmts]]</a>
244
 
245
  Each formatted input function begins execution by constructing an object
246
+ of type `ios_base::iostate`, termed the local error state, and
247
+ initializing it to `ios_base::goodbit`. It then creates an object of
248
+ 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. Otherwise,
251
+ if the `sentry` constructor exits by throwing an exception or if the
252
+ `sentry` object produces `false` when converted to a value of type
253
+ `bool`, the function returns without attempting to obtain any input. If
254
+ `rdbuf()->sbumpc()` or `rdbuf()->sgetc()` returns `traits::eof()`, then
255
+ `ios_base::eofbit` is set in the local error state and the input
256
+ function stops trying to obtain the requested input. If an exception is
257
+ thrown during input then `ios_base::badbit` is set in the local error
258
+ state, `*this`’s error state is set to the local error state, and the
259
+ exception is rethrown if `(exceptions() & badbit) != 0`. After
260
+ extraction is done, the input function calls `setstate`, which sets
261
+ `*this`’s error state to the local error state, and may throw an
262
+ exception. In any case, the formatted input function destroys the
263
+ `sentry` object. If no exception has been thrown, it returns `*this`.
264
 
265
  ##### Arithmetic extractors <a id="istream.formatted.arithmetic">[[istream.formatted.arithmetic]]</a>
266
 
267
  ``` cpp
268
+ basic_istream& operator>>(unsigned short& val);
269
+ basic_istream& operator>>(unsigned int& val);
270
+ basic_istream& operator>>(long& val);
271
+ basic_istream& operator>>(unsigned long& val);
272
+ basic_istream& operator>>(long long& val);
273
+ basic_istream& operator>>(unsigned long long& val);
274
+ basic_istream& operator>>(float& val);
275
+ basic_istream& operator>>(double& val);
276
+ basic_istream& operator>>(long double& val);
277
+ basic_istream& operator>>(bool& val);
278
+ basic_istream& operator>>(void*& val);
279
  ```
280
 
281
  As in the case of the inserters, these extractors depend on the locale’s
282
  `num_get<>` [[locale.num.get]] object to perform parsing the input
283
  stream data. These extractors behave as formatted input functions (as
284
+ described in  [[istream.formatted.reqmts]]). After a `sentry` object is
285
  constructed, the conversion occurs as if performed by the following code
286
+ fragment, where `state` represents the input function’s local error
287
+ state:
288
 
289
  ``` cpp
290
  using numget = num_get<charT, istreambuf_iterator<charT, traits>>;
291
+ use_facet<numget>(loc).get(*this, 0, *this, state, val);
 
 
292
  ```
293
 
294
  In the above fragment, `loc` stands for the private member of the
295
  `basic_ios` class.
296
 
 
301
 
302
  Class `locale` relies on this type as its interface to `istream`, so
303
  that it does not need to depend directly on `istream`.
304
 
305
  ``` cpp
306
+ basic_istream& 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
  using numget = num_get<charT, istreambuf_iterator<charT, traits>>;
 
314
  long lval;
315
+ use_facet<numget>(loc).get(*this, 0, *this, state, lval);
316
  if (lval < numeric_limits<short>::min()) {
317
+ state |= ios_base::failbit;
318
  val = numeric_limits<short>::min();
319
  } else if (numeric_limits<short>::max() < lval) {
320
+ state |= ios_base::failbit;
321
  val = numeric_limits<short>::max();
322
  } else
323
  val = static_cast<short>(lval);
 
324
  ```
325
 
326
  ``` cpp
327
+ basic_istream& operator>>(int& val);
328
  ```
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
  long lval;
336
+ use_facet<numget>(loc).get(*this, 0, *this, state, lval);
337
  if (lval < numeric_limits<int>::min()) {
338
+ state |= ios_base::failbit;
339
  val = numeric_limits<int>::min();
340
  } else if (numeric_limits<int>::max() < lval) {
341
+ state |= ios_base::failbit;
342
  val = numeric_limits<int>::max();
343
  } else
344
  val = static_cast<int>(lval);
 
345
  ```
346
 
347
+ ``` cpp
348
+ basic_istream& operator>>(extended-floating-point-type& val);
349
+ ```
350
+
351
+ If the floating-point conversion rank of
352
+ *`extended-floating-point-type`* is not less than or equal to that of
353
+ `long double`, then an invocation of the operator function is
354
+ conditionally supported with *implementation-defined* semantics.
355
+
356
+ Otherwise, let `FP` be a standard floating-point type:
357
+
358
+ - if the floating-point conversion rank of
359
+ *`extended-floating-point-type`* is less than or equal to that of
360
+ `float`, then `FP` is `float`,
361
+ - otherwise, if the floating-point conversion rank of
362
+ *`extended-floating-point-type`* is less than or equal to that of
363
+ `double`, then `FP` is `double`,
364
+ - otherwise, `FP` is `long double`.
365
+
366
+ The conversion occurs as if performed by the following code fragment
367
+ (using the same notation as for the preceding code fragment):
368
+
369
+ ``` cpp
370
+ using numget = num_get<charT, istreambuf_iterator<charT, traits>>;
371
+ FP fval;
372
+ use_facet<numget>(loc).get(*this, 0, *this, state, fval);
373
+ if (fval < -numeric_limits<extended-floating-point-type>::max()) {
374
+ state |= ios_base::failbit;
375
+ val = -numeric_limits<extended-floating-point-type>::max();
376
+ } else if (numeric_limits<extended-floating-point-type>::max() < fval) {
377
+ state |= ios_base::failbit;
378
+ val = numeric_limits<extended-floating-point-type>::max();
379
+ } else {
380
+ val = static_cast<extended-floating-point-type>(fval);
381
+ }
382
+ ```
383
+
384
+ [*Note 2*: When the extended floating-point type has a floating-point
385
+ conversion rank that is not equal to the rank of any standard
386
+ floating-point type, then double rounding during the conversion can
387
+ result in inaccurate results. `from_chars` can be used in situations
388
+ where maximum accuracy is important. — *end note*]
389
+
390
  ##### `basic_istream::operator>>` <a id="istream.extractors">[[istream.extractors]]</a>
391
 
392
  ``` cpp
393
+ basic_istream& operator>>(basic_istream& (*pf)(basic_istream&));
 
394
  ```
395
 
396
  *Effects:* None. This extractor does not behave as a formatted input
397
  function (as described in  [[istream.formatted.reqmts]]).
398
 
399
+ *Returns:* `pf(*this)`. [^20]
400
 
401
  ``` cpp
402
+ basic_istream& operator>>(basic_ios<charT, traits>& (*pf)(basic_ios<charT, traits>&));
 
403
  ```
404
 
405
  *Effects:* Calls `pf(*this)`. This extractor does not behave as a
406
  formatted input function (as described
407
  in  [[istream.formatted.reqmts]]).
408
 
409
  *Returns:* `*this`.
410
 
411
  ``` cpp
412
+ basic_istream& operator>>(ios_base& (*pf)(ios_base&));
413
  ```
414
 
415
+ *Effects:* Calls `pf(*this)`.[^21]
416
+
417
+ This extractor does not behave as a formatted input function (as
418
+ described in  [[istream.formatted.reqmts]]).
419
 
420
  *Returns:* `*this`.
421
 
422
  ``` cpp
423
  template<class charT, class traits, size_t N>
 
443
 
444
  `operator>>` then stores a null byte (`charT()`) in the next position,
445
  which may be the first position if no characters were extracted.
446
  `operator>>` then calls `width(0)`.
447
 
448
+ If the function extracted no characters, `ios_base::failbit` is set in
449
+ the input function’s local error state before `setstate` is called.
450
 
451
  *Returns:* `in`.
452
 
453
  ``` cpp
454
  template<class charT, class traits>
 
458
  template<class traits>
459
  basic_istream<char, traits>& operator>>(basic_istream<char, traits>& in, signed char& c);
460
  ```
461
 
462
  *Effects:* Behaves like a formatted input member (as described
463
+ in  [[istream.formatted.reqmts]]) of `in`. A character is extracted from
464
+ `in`, if one is available, and stored in `c`. Otherwise,
465
+ `ios_base::failbit` is set in the input function’s local error state
466
+ before `setstate` is called.
467
 
468
  *Returns:* `in`.
469
 
470
  ``` cpp
471
+ basic_istream& operator>>(basic_streambuf<charT, traits>* sb);
472
  ```
473
 
474
  *Effects:* Behaves as an unformatted input
475
  function [[istream.unformatted]]. If `sb` is null, calls
476
  `setstate(failbit)`, which may throw `ios_base::failure`
477
+ [[iostate.flags]]. After a `sentry` object is constructed, extracts
478
  characters from `*this` and inserts them in the output sequence
479
  controlled by `sb`. Characters are extracted and inserted until any of
480
  the following occurs:
481
 
482
  - end-of-file occurs on the input sequence;
483
  - inserting in the output sequence fails (in which case the character to
484
  be inserted is not extracted);
485
  - an exception occurs (in which case the exception is caught).
486
 
487
+ If the function inserts no characters, `ios_base::failbit` is set in the
488
+ input function’s local error state before `setstate` is called.
 
 
 
489
 
490
  *Returns:* `*this`.
491
 
492
  #### Unformatted input functions <a id="istream.unformatted">[[istream.unformatted]]</a>
493
 
494
  Each unformatted input function begins execution by constructing an
495
+ object of type `ios_base::iostate`, termed the local error state, and
496
+ initializing it to `ios_base::goodbit`. It then creates an object of
497
+ class `sentry` with the default argument `noskipws` (second) argument
498
+ `true`. If the `sentry` object returns `true`, when converted to a value
499
+ of type `bool`, the function endeavors to obtain the requested input.
500
+ Otherwise, if the `sentry` constructor exits by throwing an exception or
501
+ if the `sentry` object produces `false`, when converted to a value of
502
+ type `bool`, the function returns without attempting to obtain any
503
+ input. In either case the number of extracted characters is set to 0;
504
+ unformatted input functions taking a character array of nonzero size as
505
+ an argument shall also store a null character (using `charT()`) in the
506
+ first location of the array. If `rdbuf()->sbumpc()` or
507
+ `rdbuf()->sgetc()` returns `traits::eof()`, then `ios_base::eofbit` is
508
+ set in the local error state and the input function stops trying to
509
+ obtain the requested input. If an exception is thrown during input then
510
+ `ios_base::badbit` is set in the local error state, `*this`’s error
511
+ state is set to the local error state, and the exception is rethrown if
512
+ `(exceptions() & badbit) != 0`. If no exception has been thrown it
513
+ stores the number of characters extracted in a member object. After
514
+ extraction is done, the input function calls `setstate`, which sets
515
+ `*this`’s error state to the local error state, and may throw an
516
+ exception. In any event the `sentry` object is destroyed before leaving
517
+ the unformatted input function.
518
 
519
  ``` cpp
520
  streamsize gcount() const;
521
  ```
522
 
523
  *Effects:* None. This member function does not behave as an unformatted
524
  input function (as described above).
525
 
526
  *Returns:* The number of characters extracted by the last unformatted
527
+ input member function called for the object. If the number cannot be
528
+ represented, returns `numeric_limits<streamsize>::max()`.
529
 
530
  ``` cpp
531
  int_type get();
532
  ```
533
 
534
  *Effects:* Behaves as an unformatted input function (as described
535
+ above). After constructing a `sentry` object, extracts a character `c`,
536
+ if one is available. Otherwise, `ios_base::failbit` is set in the input
537
+ function’s local error state before `setstate` is called.
538
 
539
  *Returns:* `c` if available, otherwise `traits::eof()`.
540
 
541
  ``` cpp
542
+ basic_istream& get(char_type& c);
543
  ```
544
 
545
  *Effects:* Behaves as an unformatted input function (as described
546
+ above). After constructing a `sentry` object, extracts a character, if
547
+ one is available, and assigns it to `c`.[^22]
548
+
549
+ Otherwise, `ios_base::failbit` is set in the input function’s local
550
+ error state before `setstate` is called.
551
 
552
  *Returns:* `*this`.
553
 
554
  ``` cpp
555
+ basic_istream& get(char_type* s, streamsize n, char_type delim);
556
  ```
557
 
558
  *Effects:* Behaves as an unformatted input function (as described
559
+ above). After constructing a `sentry` object, extracts characters and
560
  stores them into successive locations of an array whose first element is
561
+ designated by `s`.[^23]
562
+
563
+ Characters are extracted and stored until any of the following occurs:
564
 
565
  - `n` is less than one or `n - 1` characters are stored;
566
+ - end-of-file occurs on the input sequence;
 
567
  - `traits::eq(c, delim)` for the next available input character `c` (in
568
  which case `c` is not extracted).
569
 
570
+ If the function stores no characters, `ios_base::failbit` is set in the
571
+ input function’s local error state before `setstate` is called. In any
572
+ case, if `n` is greater than zero it then stores a null character into
573
+ the next successive location of the array.
574
 
575
  *Returns:* `*this`.
576
 
577
  ``` cpp
578
+ basic_istream& get(char_type* s, streamsize n);
579
  ```
580
 
581
  *Effects:* Calls `get(s, n, widen(’\n’))`.
582
 
583
  *Returns:* Value returned by the call.
584
 
585
  ``` cpp
586
+ basic_istream& get(basic_streambuf<char_type, traits>& sb, char_type delim);
587
  ```
588
 
589
  *Effects:* Behaves as an unformatted input function (as described
590
+ above). After constructing a `sentry` object, extracts characters and
591
  inserts them in the output sequence controlled by `sb`. Characters are
592
  extracted and inserted until any of the following occurs:
593
 
594
  - end-of-file occurs on the input sequence;
595
  - inserting in the output sequence fails (in which case the character to
 
597
  - `traits::eq(c, delim)` for the next available input character `c` (in
598
  which case `c` is not extracted);
599
  - an exception occurs (in which case, the exception is caught but not
600
  rethrown).
601
 
602
+ If the function inserts no characters, `ios_base::failbit` is set in the
603
+ input function’s local error state before `setstate` is called.
604
 
605
  *Returns:* `*this`.
606
 
607
  ``` cpp
608
+ basic_istream& get(basic_streambuf<char_type, traits>& sb);
609
  ```
610
 
611
  *Effects:* Calls `get(sb, widen(’\n’))`.
612
 
613
  *Returns:* Value returned by the call.
614
 
615
  ``` cpp
616
+ basic_istream& getline(char_type* s, streamsize n, char_type delim);
617
  ```
618
 
619
  *Effects:* Behaves as an unformatted input function (as described
620
+ above). After constructing a `sentry` object, extracts characters and
621
  stores them into successive locations of an array whose first element is
622
+ designated by `s`.[^24]
 
623
 
624
+ Characters are extracted and stored until one of the following occurs:
625
+
626
+ 1. end-of-file occurs on the input sequence;
627
  2. `traits::eq(c, delim)` for the next available input character `c`
628
  (in which case the input character is extracted but not
629
+ stored);[^25]
630
  3. `n` is less than one or `n - 1` characters are stored (in which case
631
  the function calls `setstate(failbit)`).
632
 
633
+ These conditions are tested in the order shown.[^26]
634
 
635
+ If the function extracts no characters, `ios_base::failbit` is set in
636
+ the input function’s local error state before `setstate` is called.[^27]
637
 
638
  In any case, if `n` is greater than zero, it then stores a null
639
  character (using `charT()`) into the next successive location of the
640
  array.
641
 
 
669
  ```
670
 
671
  — *end example*]
672
 
673
  ``` cpp
674
+ basic_istream& getline(char_type* s, streamsize n);
675
  ```
676
 
677
  *Returns:* `getline(s, n, widen(’\n’))`
678
 
679
  ``` cpp
680
+ basic_istream& ignore(streamsize n = 1, int_type delim = traits::eof());
681
  ```
682
 
683
  *Effects:* Behaves as an unformatted input function (as described
684
+ above). After constructing a `sentry` object, extracts characters and
685
  discards them. Characters are extracted until any of the following
686
  occurs:
687
 
688
  - `n != numeric_limits<streamsize>::max()` [[numeric.limits]] and `n`
689
  characters have been extracted so far
 
691
  calls `setstate(eofbit)`, which may throw `ios_base::failure`
692
  [[iostate.flags]]);
693
  - `traits::eq_int_type(traits::to_int_type(c), delim)` for the next
694
  available input character `c` (in which case `c` is extracted).
695
 
696
+ [*Note 1*: The last condition will never occur if
697
+ `traits::eq_int_type(delim, traits::eof())`. — *end note*]
698
 
699
  *Returns:* `*this`.
700
 
701
  ``` cpp
702
  int_type peek();
703
  ```
704
 
705
  *Effects:* Behaves as an unformatted input function (as described
706
+ above). After constructing a `sentry` object, reads but does not extract
707
  the current input character.
708
 
709
  *Returns:* `traits::eof()` if `good()` is `false`. Otherwise, returns
710
  `rdbuf()->sgetc()`.
711
 
712
  ``` cpp
713
+ basic_istream& read(char_type* s, streamsize n);
714
  ```
715
 
716
  *Effects:* Behaves as an unformatted input function (as described
717
+ above). After constructing a `sentry` object, if `!good()` calls
718
  `setstate(failbit)` which may throw an exception, and return. Otherwise
719
  extracts characters and stores them into successive locations of an
720
+ array whose first element is designated by `s`.[^28]
721
+
722
+ Characters are extracted and stored until either of the following
723
+ occurs:
724
 
725
  - `n` characters are stored;
726
  - end-of-file occurs on the input sequence (in which case the function
727
  calls `setstate(failbit | eofbit)`, which may throw
728
  `ios_base::failure` [[iostate.flags]]).
 
732
  ``` cpp
733
  streamsize readsome(char_type* s, streamsize n);
734
  ```
735
 
736
  *Effects:* Behaves as an unformatted input function (as described
737
+ above). After constructing a `sentry` object, if `!good()` calls
738
  `setstate(failbit)` which may throw an exception, and return. Otherwise
739
  extracts characters and stores them into successive locations of an
740
  array whose first element is designated by `s`. If
741
  `rdbuf()->in_avail() == -1`, calls `setstate(eofbit)` (which may throw
742
  `ios_base::failure` [[iostate.flags]]), and extracts no characters;
 
745
  - If `rdbuf()->in_avail() > 0`, extracts `min(rdbuf()->in_avail(), n))`.
746
 
747
  *Returns:* The number of characters extracted.
748
 
749
  ``` cpp
750
+ basic_istream& putback(char_type c);
751
  ```
752
 
753
  *Effects:* Behaves as an unformatted input function (as described
754
  above), except that the function first clears `eofbit`. After
755
+ constructing a `sentry` object, if `!good()` calls `setstate(failbit)`
756
  which may throw an exception, and return. If `rdbuf()` is not null,
757
  calls `rdbuf()->sputbackc(c)`. If `rdbuf()` is null, or if `sputbackc`
758
  returns `traits::eof()`, calls `setstate(badbit)` (which may throw
759
  `ios_base::failure` [[iostate.flags]]).
760
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
761
  [*Note 2*: This function extracts no characters, so the value returned
762
  by the next call to `gcount()` is 0. — *end note*]
763
 
764
  *Returns:* `*this`.
765
 
766
+ ``` cpp
767
+ basic_istream& unget();
768
+ ```
769
+
770
+ *Effects:* Behaves as an unformatted input function (as described
771
+ above), except that the function first clears `eofbit`. After
772
+ constructing a `sentry` object, if `!good()` calls `setstate(failbit)`
773
+ which may throw an exception, and return. If `rdbuf()` is not null,
774
+ calls `rdbuf()->sungetc()`. If `rdbuf()` is null, or if `sungetc`
775
+ returns `traits::eof()`, calls `setstate(badbit)` (which may throw
776
+ `ios_base::failure` [[iostate.flags]]).
777
+
778
+ [*Note 3*: This function extracts no characters, so the value returned
779
+ by the next call to `gcount()` is 0. — *end note*]
780
+
781
+ *Returns:* `*this`.
782
+
783
  ``` cpp
784
  int sync();
785
  ```
786
 
787
  *Effects:* Behaves as an unformatted input function (as described
788
  above), except that it does not count the number of characters extracted
789
  and does not affect the value returned by subsequent calls to
790
+ `gcount()`. After constructing a `sentry` object, if `rdbuf()` is a null
791
  pointer, returns `-1`. Otherwise, calls `rdbuf()->pubsync()` and, if
792
  that function returns `-1` calls `setstate(badbit)` (which may throw
793
  `ios_base::failure` [[iostate.flags]], and returns `-1`. Otherwise,
794
  returns zero.
795
 
 
800
  *Effects:* Behaves as an unformatted input function (as described
801
  above), except that it does not count the number of characters extracted
802
  and does not affect the value returned by subsequent calls to
803
  `gcount()`.
804
 
805
+ *Returns:* After constructing a `sentry` object, if `fail() != false`,
806
  returns `pos_type(-1)` to indicate failure. Otherwise, returns
807
  `rdbuf()->pubseekoff(0, cur, in)`.
808
 
809
  ``` cpp
810
+ basic_istream& seekg(pos_type pos);
811
  ```
812
 
813
  *Effects:* Behaves as an unformatted input function (as described
814
  above), except that the function first clears `eofbit`, it does not
815
  count the number of characters extracted, and it does not affect the
816
  value returned by subsequent calls to `gcount()`. After constructing a
817
+ `sentry` object, if `fail() != true`, executes
818
  `rdbuf()->pubseekpos(pos, ios_base::in)`. In case of failure, the
819
  function calls `setstate(failbit)` (which may throw
820
  `ios_base::failure`).
821
 
822
  *Returns:* `*this`.
823
 
824
  ``` cpp
825
+ basic_istream& seekg(off_type off, ios_base::seekdir dir);
826
  ```
827
 
828
  *Effects:* Behaves as an unformatted input function (as described
829
  above), except that the function first clears `eofbit`, does not count
830
  the number of characters extracted, and does not affect the value
831
+ returned by subsequent calls to `gcount()`. After constructing a
832
+ `sentry` object, if `fail() != true`, executes
833
  `rdbuf()->pubseekoff(off, dir, ios_base::in)`. In case of failure, the
834
  function calls `setstate(failbit)` (which may throw
835
  `ios_base::failure`).
836
 
837
  *Returns:* `*this`.
 
847
  ```
848
 
849
  *Effects:* Behaves as an unformatted input
850
  function [[istream.unformatted]], except that it does not count the
851
  number of characters extracted and does not affect the value returned by
852
+ subsequent calls to `is.gcount()`. After constructing a `sentry` object
853
  extracts characters as long as the next available character `c` is
854
  whitespace or until there are no more characters in the sequence.
855
  Whitespace characters are distinguished with the same criterion as used
856
  by `sentry::sentry` [[istream.sentry]]. If `ws` stops extracting
857
  characters because there are no more available it sets `eofbit`, but not
 
865
  template<class Istream, class T>
866
  Istream&& operator>>(Istream&& is, T&& x);
867
  ```
868
 
869
  *Constraints:* The expression `is >> std::forward<T>(x)` is well-formed
870
+ when treated as an unevaluated operand [[term.unevaluated.operand]] and
871
+ `Istream` is publicly and unambiguously derived from `ios_base`.
872
 
873
  *Effects:* Equivalent to:
874
 
875
  ``` cpp
876
  is >> std::forward<T>(x);
877
  return std::move(is);
878
  ```
879
 
880
  #### Class template `basic_iostream` <a id="iostreamclass">[[iostreamclass]]</a>
881
 
882
+ ##### General <a id="iostreamclass.general">[[iostreamclass.general]]</a>
883
+
884
  ``` cpp
885
  namespace std {
886
  template<class charT, class traits = char_traits<charT>>
887
  class basic_iostream
888
  : public basic_istream<charT, traits>,
 
903
  protected:
904
  // [iostream.cons], constructor
905
  basic_iostream(const basic_iostream&) = delete;
906
  basic_iostream(basic_iostream&& rhs);
907
 
908
+ // [iostream.assign], assignment and swap
909
  basic_iostream& operator=(const basic_iostream&) = delete;
910
  basic_iostream& operator=(basic_iostream&& rhs);
911
  void swap(basic_iostream& rhs);
912
  };
913
  }
 
932
  ``` cpp
933
  basic_iostream(basic_iostream&& rhs);
934
  ```
935
 
936
  *Effects:* Move constructs from the rvalue `rhs` by constructing the
937
+ `basic_istream` base class with `std::move(rhs)`.
938
 
939
  ##### Destructor <a id="iostream.dest">[[iostream.dest]]</a>
940
 
941
  ``` cpp
942
  virtual ~basic_iostream();