From Jason Turner

[iostreams.base]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmpmwdaqd99/{from.md → to.md} +175 -158
tmp/tmpmwdaqd99/{from.md → to.md} RENAMED
@@ -88,11 +88,11 @@ an I/O operation, or the size of I/O buffers.[^5]
88
  namespace std {
89
  class ios_base {
90
  public:
91
  class failure; // see below
92
 
93
- // [ios::fmtflags], fmtflags
94
  using fmtflags = T1;
95
  static constexpr fmtflags boolalpha = unspecified;
96
  static constexpr fmtflags dec = unspecified;
97
  static constexpr fmtflags fixed = unspecified;
98
  static constexpr fmtflags hex = unspecified;
@@ -109,27 +109,27 @@ namespace std {
109
  static constexpr fmtflags uppercase = unspecified;
110
  static constexpr fmtflags adjustfield = see below;
111
  static constexpr fmtflags basefield = see below;
112
  static constexpr fmtflags floatfield = see below;
113
 
114
- // [ios::iostate], iostate
115
  using iostate = T2;
116
  static constexpr iostate badbit = unspecified;
117
  static constexpr iostate eofbit = unspecified;
118
  static constexpr iostate failbit = unspecified;
119
  static constexpr iostate goodbit = see below;
120
 
121
- // [ios::openmode], openmode
122
  using openmode = T3;
123
  static constexpr openmode app = unspecified;
124
  static constexpr openmode ate = unspecified;
125
  static constexpr openmode binary = unspecified;
126
  static constexpr openmode in = unspecified;
127
  static constexpr openmode out = unspecified;
128
  static constexpr openmode trunc = unspecified;
129
 
130
- // [ios::seekdir], seekdir
131
  using seekdir = T4;
132
  static constexpr seekdir beg = unspecified;
133
  static constexpr seekdir cur = unspecified;
134
  static constexpr seekdir end = unspecified;
135
 
@@ -151,20 +151,20 @@ namespace std {
151
  locale imbue(const locale& loc);
152
  locale getloc() const;
153
 
154
  // [ios.base.storage], storage
155
  static int xalloc();
156
- long& iword(int index);
157
- void*& pword(int index);
158
 
159
- // destructor:
160
  virtual ~ios_base();
161
 
162
- // [ios.base.callback], callbacks;
163
  enum event { erase_event, imbue_event, copyfmt_event };
164
- using event_callback = void (*)(event, ios_base&, int index);
165
- void register_callback(event_callback fn, int index);
166
 
167
  ios_base(const ios_base&) = delete;
168
  ios_base& operator=(const ios_base&) = delete;
169
 
170
  static bool sync_with_stdio(bool sync = true);
@@ -212,11 +212,11 @@ For the sake of exposition, the maintained data is presented here as:
212
 
213
  — *end note*]
214
 
215
  #### Types <a id="ios.types">[[ios.types]]</a>
216
 
217
- ##### Class `ios_base::failure` <a id="ios::failure">[[ios::failure]]</a>
218
 
219
  ``` cpp
220
  namespace std {
221
  class ios_base::failure : public system_error {
222
  public:
@@ -228,13 +228,13 @@ namespace std {
228
 
229
  An implementation is permitted to define `ios_base::failure` as a
230
  synonym for a class with equivalent functionality to class
231
  `ios_base::failure` shown in this subclause.
232
 
233
- [*Note 1*: When `ios_base::failure` is a synonym for another type it
234
- shall provide a nested type `failure`, to emulate the injected class
235
- name. — *end note*]
236
 
237
  The class `failure` defines the base class for the types of all objects
238
  thrown as exceptions, by functions in the iostreams library, to report
239
  errors detected during stream buffer operations.
240
 
@@ -251,31 +251,28 @@ iostream_category())`. — *end note*]
251
 
252
  ``` cpp
253
  explicit failure(const string& msg, const error_code& ec = io_errc::stream);
254
  ```
255
 
256
- *Effects:* Constructs an object of class `failure` by constructing the
257
- base class with `msg` and `ec`.
258
 
259
  ``` cpp
260
  explicit failure(const char* msg, const error_code& ec = io_errc::stream);
261
  ```
262
 
263
- *Effects:* Constructs an object of class `failure` by constructing the
264
- base class with `msg` and `ec`.
265
 
266
- ##### Type `ios_base::fmtflags` <a id="ios::fmtflags">[[ios::fmtflags]]</a>
267
 
268
  ``` cpp
269
  using fmtflags = T1;
270
  ```
271
 
272
- The type `fmtflags` is a bitmask type ([[bitmask.types]]). Setting its
273
- elements has the effects indicated in
274
- Table  [[tab:iostreams.fmtflags.effects]].
275
 
276
- **Table: `fmtflags` effects** <a id="tab:iostreams.fmtflags.effects">[tab:iostreams.fmtflags.effects]</a>
277
 
278
  | Element | Effect(s) if set |
279
  | ------------ | --------------------------------------------------------------------------------------------------------------------------------------- |
280
  | `boolalpha` | insert and extract `bool` type in alphabetic format |
281
  | `dec` | converts integer input or generates integer output in decimal base |
@@ -293,31 +290,31 @@ Table  [[tab:iostreams.fmtflags.effects]].
293
  | `unitbuf` | flushes output after each output operation |
294
  | `uppercase` | replaces certain lowercase letters with their uppercase equivalents in generated output |
295
 
296
 
297
  Type `fmtflags` also defines the constants indicated in
298
- Table  [[tab:iostreams.fmtflags.constants]].
299
 
300
- **Table: `fmtflags` constants** <a id="tab:iostreams.fmtflags.constants">[tab:iostreams.fmtflags.constants]</a>
301
 
302
  | Constant | Allowable values |
303
  | ------------- | ------------------------- |
304
  | `adjustfield` | `left | right | internal` |
305
  | `basefield` | `dec | oct | hex` |
306
  | `floatfield` | `scientific | fixed` |
307
 
308
 
309
- ##### Type `ios_base::iostate` <a id="ios::iostate">[[ios::iostate]]</a>
310
 
311
  ``` cpp
312
  using iostate = T2;
313
  ```
314
 
315
- The type `iostate` is a bitmask type ([[bitmask.types]]) that contains
316
- the elements indicated in Table  [[tab:iostreams.iostate.effects]].
317
 
318
- **Table: `iostate` effects** <a id="tab:iostreams.iostate.effects">[tab:iostreams.iostate.effects]</a>
319
 
320
  | Element | Effect(s) if set |
321
  | --------- | ------------------------------------------------------------------------------------------------------------------------------------------------ |
322
  | `badbit` | indicates a loss of integrity in an input or output sequence (such as an irrecoverable read error from a file); |
323
  | `eofbit` | indicates that an input operation reached the end of an input sequence; |
@@ -326,20 +323,20 @@ the elements indicated in Table  [[tab:iostreams.iostate.effects]].
326
 
327
  Type `iostate` also defines the constant:
328
 
329
  - `goodbit`, the value zero.
330
 
331
- ##### Type `ios_base::openmode` <a id="ios::openmode">[[ios::openmode]]</a>
332
 
333
  ``` cpp
334
  using openmode = T3;
335
  ```
336
 
337
- The type `openmode` is a bitmask type ([[bitmask.types]]). It contains
338
- the elements indicated in Table  [[tab:iostreams.openmode.effects]].
339
 
340
- **Table: `openmode` effects** <a id="tab:iostreams.openmode.effects">[tab:iostreams.openmode.effects]</a>
341
 
342
  | Element | Effect(s) if set |
343
  | -------- | ----------------------------------------------------------------- |
344
  | `app` | seek to end before each write |
345
  | `ate` | open and seek to end immediately after opening |
@@ -347,73 +344,71 @@ the elements indicated in Table  [[tab:iostreams.openmode.effects]].
347
  | `in` | open for input |
348
  | `out` | open for output |
349
  | `trunc` | truncate an existing stream when opening |
350
 
351
 
352
- ##### Type `ios_base::seekdir` <a id="ios::seekdir">[[ios::seekdir]]</a>
353
 
354
  ``` cpp
355
  using seekdir = T4;
356
  ```
357
 
358
- The type `seekdir` is an enumerated type ([[enumerated.types]]) that
359
- contains the elements indicated in
360
- Table  [[tab:iostreams.seekdir.effects]].
361
 
362
- **Table: `seekdir` effects** <a id="tab:iostreams.seekdir.effects">[tab:iostreams.seekdir.effects]</a>
363
 
364
  | Element | Meaning |
365
  | ------- | --------------------------------------------------------------------------------------- |
366
  | `beg` | request a seek (for subsequent input or output) relative to the beginning of the stream |
367
  | `cur` | request a seek relative to the current position within the sequence |
368
  | `end` | request a seek relative to the current end of the sequence |
369
 
370
 
371
- ##### Class `ios_base::Init` <a id="ios::Init">[[ios::Init]]</a>
372
 
373
  ``` cpp
374
  namespace std {
375
  class ios_base::Init {
376
  public:
377
  Init();
 
378
  ~Init();
 
379
  private:
380
  static int init_cnt; // exposition only
381
  };
382
  }
383
  ```
384
 
385
  The class `Init` describes an object whose construction ensures the
386
- construction of the eight objects declared in `<iostream>` (
387
- [[iostream.objects]]) that associate file stream buffers with the
388
- standard C streams provided for by the functions declared in
389
- `<cstdio>` ([[cstdio.syn]]).
390
 
391
  For the sake of exposition, the maintained data is presented here as:
392
 
393
  - `static int init_cnt`, counts the number of constructor and destructor
394
  calls for class `Init`, initialized to zero.
395
 
396
  ``` cpp
397
  Init();
398
  ```
399
 
400
- *Effects:* Constructs an object of class `Init`. Constructs and
401
- initializes the objects `cin`, `cout`, `cerr`, `clog`, `wcin`, `wcout`,
402
- `wcerr`, and `wclog` if they have not already been constructed and
403
- initialized.
404
 
405
  ``` cpp
406
  ~Init();
407
  ```
408
 
409
- *Effects:* Destroys an object of class `Init`. If there are no other
410
- instances of the class still in existence, calls `cout.flush()`,
411
- `cerr.flush()`, `clog.flush()`, `wcout.flush()`, `wcerr.flush()`,
412
- `wclog.flush()`.
413
 
414
- #### `ios_base` state functions <a id="fmtflags.state">[[fmtflags.state]]</a>
415
 
416
  ``` cpp
417
  fmtflags flags() const;
418
  ```
419
 
@@ -421,11 +416,11 @@ fmtflags flags() const;
421
 
422
  ``` cpp
423
  fmtflags flags(fmtflags fmtfl);
424
  ```
425
 
426
- *Postconditions:* `fmtfl == flags()`.
427
 
428
  *Returns:* The previous value of `flags()`.
429
 
430
  ``` cpp
431
  fmtflags setf(fmtflags fmtfl);
@@ -457,11 +452,11 @@ streamsize precision() const;
457
 
458
  ``` cpp
459
  streamsize precision(streamsize prec);
460
  ```
461
 
462
- *Postconditions:* `prec == precision()`.
463
 
464
  *Returns:* The previous value of `precision()`.
465
 
466
  ``` cpp
467
  streamsize width() const;
@@ -472,47 +467,46 @@ certain output conversions.
472
 
473
  ``` cpp
474
  streamsize width(streamsize wide);
475
  ```
476
 
477
- *Postconditions:* `wide == width()`.
478
 
479
  *Returns:* The previous value of `width()`.
480
 
481
- #### `ios_base` functions <a id="ios.base.locales">[[ios.base.locales]]</a>
482
 
483
  ``` cpp
484
  locale imbue(const locale& loc);
485
  ```
486
 
487
- *Effects:* Calls each registered callback pair
488
- `(fn, index)` ([[ios.base.callback]]) as
489
- `(*fn)(imbue_event, *this, index)` at such a time that a call to
490
- `ios_base::getloc()` from within `fn` returns the new locale value
491
- `loc`.
 
492
 
493
  *Returns:* The previous value of `getloc()`.
494
 
495
- *Postconditions:* `loc == getloc()`.
496
-
497
  ``` cpp
498
  locale getloc() const;
499
  ```
500
 
501
- *Returns:* If no locale has been imbued, a copy of the global C++locale,
502
- `locale()`, in effect at the time of construction. Otherwise, returns
503
- the imbued locale, to be used to perform locale-dependent input and
504
- output operations.
505
 
506
- #### `ios_base` static members <a id="ios.members.static">[[ios.members.static]]</a>
507
 
508
  ``` cpp
509
- bool sync_with_stdio(bool sync = true);
510
  ```
511
 
512
  *Returns:* `true` if the previous state of the standard iostream
513
- objects ([[iostream.objects]]) was synchronized and otherwise returns
514
  `false`. The first time it is called, the function returns `true`.
515
 
516
  *Effects:* If any input or output operation has occurred using the
517
  standard streams prior to the call, the effect is
518
  *implementation-defined*. Otherwise, called with a `false` argument, it
@@ -558,25 +552,27 @@ is the same as the effect of
558
  str.rdbuf()->sputbackc(c);
559
  ```
560
 
561
  for any sequence of characters.[^6]
562
 
563
- #### `ios_base` storage functions <a id="ios.base.storage">[[ios.base.storage]]</a>
564
 
565
  ``` cpp
566
  static int xalloc();
567
  ```
568
 
569
  *Returns:* `index` `++`.
570
 
571
- *Remarks:* Concurrent access to this function by multiple threads shall
572
- not result in a data race ([[intro.multithread]]).
573
 
574
  ``` cpp
575
  long& iword(int idx);
576
  ```
577
 
 
 
578
  *Effects:* If `iarray` is a null pointer, allocates an array of `long`
579
  of unspecified size and stores a pointer to its first element in
580
  `iarray`. The function then extends the array pointed at by `iarray` as
581
  necessary to include the element `iarray[idx]`. Each newly allocated
582
  element of the array is initialized to zero. The reference returned is
@@ -593,10 +589,12 @@ initialized to 0.
593
 
594
  ``` cpp
595
  void*& pword(int idx);
596
  ```
597
 
 
 
598
  *Effects:* If `parray` is a null pointer, allocates an array of pointers
599
  to `void` of unspecified size and stores a pointer to its first element
600
  in `parray`. The function then extends the array pointed at by `parray`
601
  as necessary to include the element `parray[idx]`. Each newly allocated
602
  element of the array is initialized to a null pointer. The reference
@@ -612,29 +610,29 @@ object (which may throw `failure`).
612
  initialized to 0.
613
 
614
  *Remarks:* After a subsequent call to `pword(int)` for the same object,
615
  the earlier return value may no longer be valid.
616
 
617
- #### `ios_base` callbacks <a id="ios.base.callback">[[ios.base.callback]]</a>
618
 
619
  ``` cpp
620
- void register_callback(event_callback fn, int index);
621
  ```
622
 
623
- *Effects:* Registers the pair `(fn, index)` such that during calls to
624
- `imbue()` ([[ios.base.locales]]), `copyfmt()`, or
625
- `~ios_base()` ([[ios.base.cons]]), the function `fn` is called with
626
- argument `index`. Functions registered are called when an event occurs,
627
- in opposite order of registration. Functions registered while a callback
628
- function is active are not called until the next event.
629
 
630
- *Requires:* The function `fn` shall not throw exceptions.
 
 
 
 
 
631
 
632
  *Remarks:* Identical pairs are not merged. A function registered twice
633
  will be called twice.
634
 
635
- #### `ios_base` constructors/destructor <a id="ios.base.cons">[[ios.base.cons]]</a>
636
 
637
  ``` cpp
638
  ios_base();
639
  ```
640
 
@@ -645,14 +643,14 @@ destroyed, whichever comes first; otherwise the behavior is undefined.
645
 
646
  ``` cpp
647
  ~ios_base();
648
  ```
649
 
650
- *Effects:* Destroys an object of class `ios_base`. Calls each registered
651
- callback pair `(fn, index)` ([[ios.base.callback]]) as
652
- `(*fn)(erase_event, *this, index)` at such time that any `ios_base`
653
- member function called from within `fn` has well defined results.
654
 
655
  ### Class template `fpos` <a id="fpos">[[fpos]]</a>
656
 
657
  ``` cpp
658
  namespace std {
@@ -665,11 +663,11 @@ namespace std {
665
  stateT st; // exposition only
666
  };
667
  }
668
  ```
669
 
670
- #### `fpos` members <a id="fpos.members">[[fpos.members]]</a>
671
 
672
  ``` cpp
673
  void state(stateT s);
674
  ```
675
 
@@ -679,27 +677,36 @@ void state(stateT s);
679
  stateT state() const;
680
  ```
681
 
682
  *Returns:* Current value of `st`.
683
 
684
- #### `fpos` requirements <a id="fpos.operations">[[fpos.operations]]</a>
685
 
686
- Operations specified in Table  [[tab:iostreams.position.requirements]]
687
- are permitted. In that table,
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
688
 
689
  - `P` refers to an instance of `fpos`,
690
- - `p` and `q` refer to values of type `P`,
691
- - `O` refers to type `streamoff`,
692
- - `o` refers to a value of type `streamoff`,
693
- - `sz` refers to a value of type `streamsize` and
694
- - `i` refers to a value of type `int`.
695
-
696
- [*Note 1*: Every implementation is required to supply overloaded
697
- operators on `fpos` objects to satisfy the requirements of 
698
- [[fpos.operations]]. It is unspecified whether these operators are
699
- members of `fpos`, global operators, or provided in some other
700
- way. — *end note*]
701
 
702
  Stream operations that return a value of type `traits::pos_type` return
703
  `P(O(-1))` as an invalid value to signal an error. If this value is used
704
  as an argument to any `istream`, `ostream`, or `streambuf` member that
705
  accepts a value of type `traits::pos_type` then the behavior of that
@@ -768,28 +775,27 @@ namespace std {
768
 
769
  };
770
  }
771
  ```
772
 
773
- #### `basic_ios` constructors <a id="basic.ios.cons">[[basic.ios.cons]]</a>
774
 
775
  ``` cpp
776
  explicit basic_ios(basic_streambuf<charT, traits>* sb);
777
  ```
778
 
779
- *Effects:* Constructs an object of class `basic_ios`, assigning initial
780
- values to its member objects by calling `init(sb)`.
781
 
782
  ``` cpp
783
  basic_ios();
784
  ```
785
 
786
- *Effects:* Constructs an object of class
787
- `basic_ios` ([[ios.base.cons]]) leaving its member objects
788
- uninitialized. The object shall be initialized by calling
789
- `basic_ios::init` before its first use or before it is destroyed,
790
- whichever comes first; otherwise the behavior is undefined.
791
 
792
  ``` cpp
793
  ~basic_ios();
794
  ```
795
 
@@ -797,14 +803,14 @@ whichever comes first; otherwise the behavior is undefined.
797
 
798
  ``` cpp
799
  void init(basic_streambuf<charT, traits>* sb);
800
  ```
801
 
802
- *Postconditions:* The postconditions of this function are indicated in
803
- Table  [[tab:iostreams.basicios.init.effects]].
804
 
805
- **Table: `basic_ios::init()` effects** <a id="tab:iostreams.basicios.init.effects">[tab:iostreams.basicios.init.effects]</a>
806
 
807
  | Element | Value |
808
  | -------------- | ------------------------------------------------------------ |
809
  | `rdbuf()` | `sb` |
810
  | `tie()` | `0` |
@@ -830,15 +836,15 @@ sequence controlled by the stream buffer.
830
 
831
  ``` cpp
832
  basic_ostream<charT, traits>* tie(basic_ostream<charT, traits>* tiestr);
833
  ```
834
 
835
- *Requires:* If `tiestr` is not null, `tiestr` must not be reachable by
836
  traversing the linked list of tied stream objects starting from
837
  `tiestr->tie()`.
838
 
839
- *Postconditions:* `tiestr == tie()`.
840
 
841
  *Returns:* The previous value of `tie()`.
842
 
843
  ``` cpp
844
  basic_streambuf<charT, traits>* rdbuf() const;
@@ -848,22 +854,22 @@ basic_streambuf<charT, traits>* rdbuf() const;
848
 
849
  ``` cpp
850
  basic_streambuf<charT, traits>* rdbuf(basic_streambuf<charT, traits>* sb);
851
  ```
852
 
853
- *Postconditions:* `sb == rdbuf()`.
854
-
855
  *Effects:* Calls `clear()`.
856
 
 
 
857
  *Returns:* The previous value of `rdbuf()`.
858
 
859
  ``` cpp
860
  locale imbue(const locale& loc);
861
  ```
862
 
863
- *Effects:* Calls `ios_base::imbue(loc)` ([[ios.base.locales]]) and if
864
- `rdbuf() != 0` then `rdbuf()->pubimbue(loc)` ([[streambuf.locales]]).
865
 
866
  *Returns:* The prior value of `ios_base::imbue()`.
867
 
868
  ``` cpp
869
  char narrow(char_type c, char dfault) const;
@@ -886,45 +892,45 @@ specified field width.
886
 
887
  ``` cpp
888
  char_type fill(char_type fillch);
889
  ```
890
 
891
- *Postconditions:* `traits::eq(fillch, fill())`.
892
 
893
  *Returns:* The previous value of `fill()`.
894
 
895
  ``` cpp
896
  basic_ios& copyfmt(const basic_ios& rhs);
897
  ```
898
 
899
- *Effects:* If `(this == &rhs)` does nothing. Otherwise assigns to the
900
- member objects of `*this` the corresponding member objects of `rhs` as
901
- follows:
902
 
903
- 1. calls each registered callback pair `(fn, index)` as
904
- `(*fn)(erase_event, *this, index)`;
905
- 2. assigns to the member objects of `*this` the corresponding member
906
- objects of `rhs`, except that
907
  - `rdstate()`, `rdbuf()`, and `exceptions()` are left unchanged;
908
- - the contents of arrays pointed at by `pword` and `iword` are
909
- copied, not the pointers themselves;[^10] and
910
  - if any newly stored pointer values in `*this` point at objects
911
- stored outside the object `rhs` and those objects are destroyed
912
- when `rhs` is destroyed, the newly stored pointer values are
913
- altered to point at newly constructed copies of the objects;
914
- 3. calls each callback pair that was copied from `rhs` as
915
- `(*fn)(copyfmt_event, *this, index)`;
916
- 4. calls `exceptions(rhs.exceptions())`.
917
 
918
  [*Note 1*: The second pass through the callback pairs permits a copied
919
  `pword` value to be zeroed, or to have its referent deep copied or
920
  reference counted, or to have other special action taken. — *end note*]
921
 
922
- *Postconditions:* The postconditions of this function are indicated in
923
- Table  [[tab:iostreams.copyfmt.effects]].
924
 
925
- **Table: `basic_ios::copyfmt()` effects** <a id="tab:iostreams.copyfmt.effects">[tab:iostreams.copyfmt.effects]</a>
926
 
927
  | Element | Value |
928
  | -------------- | ------------------ |
929
  | `rdbuf()` | unchanged |
930
  | `tie()` | `rhs.tie()` |
@@ -942,39 +948,38 @@ Table  [[tab:iostreams.copyfmt.effects]].
942
  ``` cpp
943
  void move(basic_ios& rhs);
944
  void move(basic_ios&& rhs);
945
  ```
946
 
947
- *Postconditions:* `*this` shall have the state that `rhs` had before the
948
- function call, except that `rdbuf()` shall return 0. `rhs` shall be in a
949
- valid but unspecified state, except that `rhs.rdbuf()` shall return the
950
- same value as it returned before the function call, and `rhs.tie()`
951
- shall return 0.
952
 
953
  ``` cpp
954
  void swap(basic_ios& rhs) noexcept;
955
  ```
956
 
957
- *Effects:* The states of `*this` and `rhs` shall be exchanged, except
958
- that `rdbuf()` shall return the same value as it returned before the
959
- function call, and `rhs.rdbuf()` shall return the same value as it
960
- returned before the function call.
961
 
962
  ``` cpp
963
  void set_rdbuf(basic_streambuf<charT, traits>* sb);
964
  ```
965
 
966
- *Requires:* `sb != nullptr`.
967
 
968
  *Effects:* Associates the `basic_streambuf` object pointed to by `sb`
969
  with this stream without calling `clear()`.
970
 
971
- *Postconditions:* `rdbuf() == sb`.
972
 
973
  *Throws:* Nothing.
974
 
975
- #### `basic_ios` flags functions <a id="iostate.flags">[[iostate.flags]]</a>
976
 
977
  ``` cpp
978
  explicit operator bool() const;
979
  ```
980
 
@@ -994,25 +999,25 @@ iostate rdstate() const;
994
 
995
  ``` cpp
996
  void clear(iostate state = goodbit);
997
  ```
998
 
999
- *Postconditions:* If `rdbuf() != 0` then `state == rdstate()`; otherwise
1000
  `rdstate() == (state | ios_base::badbit)`.
1001
 
1002
  *Effects:* If
1003
  `((state | (rdbuf() ? goodbit : badbit)) & exceptions()) == 0`, returns.
1004
- Otherwise, the function throws an object of class
1005
- `basic_ios::failure` ([[ios::failure]]), constructed with
1006
- *implementation-defined* argument values.
1007
 
1008
  ``` cpp
1009
  void setstate(iostate state);
1010
  ```
1011
 
1012
  *Effects:* Calls `clear(rdstate() | state)` (which may throw
1013
- `basic_ios::failure` ([[ios::failure]])).
1014
 
1015
  ``` cpp
1016
  bool good() const;
1017
  ```
1018
 
@@ -1045,18 +1050,21 @@ exceptions to be thrown.
1045
 
1046
  ``` cpp
1047
  void exceptions(iostate except);
1048
  ```
1049
 
1050
- *Postconditions:* `except == exceptions()`.
1051
 
1052
  *Effects:* Calls `clear(rdstate())`.
1053
 
1054
  ### `ios_base` manipulators <a id="std.ios.manip">[[std.ios.manip]]</a>
1055
 
1056
  #### `fmtflags` manipulators <a id="fmtflags.manip">[[fmtflags.manip]]</a>
1057
 
 
 
 
1058
  ``` cpp
1059
  ios_base& boolalpha(ios_base& str);
1060
  ```
1061
 
1062
  *Effects:* Calls `str.setf(ios_base::boolalpha)`.
@@ -1167,10 +1175,13 @@ ios_base& nounitbuf(ios_base& str);
1167
 
1168
  *Returns:* `str`.
1169
 
1170
  #### `adjustfield` manipulators <a id="adjustfield.manip">[[adjustfield.manip]]</a>
1171
 
 
 
 
1172
  ``` cpp
1173
  ios_base& internal(ios_base& str);
1174
  ```
1175
 
1176
  *Effects:* Calls `str.setf(ios_base::internal, ios_base::adjustfield)`.
@@ -1193,10 +1204,13 @@ ios_base& right(ios_base& str);
1193
 
1194
  *Returns:* `str`.
1195
 
1196
  #### `basefield` manipulators <a id="basefield.manip">[[basefield.manip]]</a>
1197
 
 
 
 
1198
  ``` cpp
1199
  ios_base& dec(ios_base& str);
1200
  ```
1201
 
1202
  *Effects:* Calls `str.setf(ios_base::dec, ios_base::basefield)`.
@@ -1219,10 +1233,13 @@ ios_base& oct(ios_base& str);
1219
 
1220
  *Returns:* `str`.
1221
 
1222
  #### `floatfield` manipulators <a id="floatfield.manip">[[floatfield.manip]]</a>
1223
 
 
 
 
1224
  ``` cpp
1225
  ios_base& fixed(ios_base& str);
1226
  ```
1227
 
1228
  *Effects:* Calls `str.setf(ios_base::fixed, ios_base::floatfield)`.
@@ -1246,22 +1263,22 @@ ios_base& hexfloat(ios_base& str);
1246
 
1247
  *Returns:* `str`.
1248
 
1249
  [*Note 1*: The more obvious use of `ios_base::hex` to specify
1250
  hexadecimal floating-point format would change the meaning of existing
1251
- well defined programs. C++03 gives no meaning to the combination of
1252
  `fixed` and `scientific`. — *end note*]
1253
 
1254
  ``` cpp
1255
  ios_base& defaultfloat(ios_base& str);
1256
  ```
1257
 
1258
  *Effects:* Calls `str.unsetf(ios_base::floatfield)`.
1259
 
1260
  *Returns:* `str`.
1261
 
1262
- #### Error reporting <a id="error.reporting">[[error.reporting]]</a>
1263
 
1264
  ``` cpp
1265
  error_code make_error_code(io_errc e) noexcept;
1266
  ```
1267
 
 
88
  namespace std {
89
  class ios_base {
90
  public:
91
  class failure; // see below
92
 
93
+ // [ios.fmtflags], fmtflags
94
  using fmtflags = T1;
95
  static constexpr fmtflags boolalpha = unspecified;
96
  static constexpr fmtflags dec = unspecified;
97
  static constexpr fmtflags fixed = unspecified;
98
  static constexpr fmtflags hex = unspecified;
 
109
  static constexpr fmtflags uppercase = unspecified;
110
  static constexpr fmtflags adjustfield = see below;
111
  static constexpr fmtflags basefield = see below;
112
  static constexpr fmtflags floatfield = see below;
113
 
114
+ // [ios.iostate], iostate
115
  using iostate = T2;
116
  static constexpr iostate badbit = unspecified;
117
  static constexpr iostate eofbit = unspecified;
118
  static constexpr iostate failbit = unspecified;
119
  static constexpr iostate goodbit = see below;
120
 
121
+ // [ios.openmode], openmode
122
  using openmode = T3;
123
  static constexpr openmode app = unspecified;
124
  static constexpr openmode ate = unspecified;
125
  static constexpr openmode binary = unspecified;
126
  static constexpr openmode in = unspecified;
127
  static constexpr openmode out = unspecified;
128
  static constexpr openmode trunc = unspecified;
129
 
130
+ // [ios.seekdir], seekdir
131
  using seekdir = T4;
132
  static constexpr seekdir beg = unspecified;
133
  static constexpr seekdir cur = unspecified;
134
  static constexpr seekdir end = unspecified;
135
 
 
151
  locale imbue(const locale& loc);
152
  locale getloc() const;
153
 
154
  // [ios.base.storage], storage
155
  static int xalloc();
156
+ long& iword(int idx);
157
+ void*& pword(int idx);
158
 
159
+ // destructor
160
  virtual ~ios_base();
161
 
162
+ // [ios.base.callback], callbacks
163
  enum event { erase_event, imbue_event, copyfmt_event };
164
+ using event_callback = void (*)(event, ios_base&, int idx);
165
+ void register_callback(event_callback fn, int idx);
166
 
167
  ios_base(const ios_base&) = delete;
168
  ios_base& operator=(const ios_base&) = delete;
169
 
170
  static bool sync_with_stdio(bool sync = true);
 
212
 
213
  — *end note*]
214
 
215
  #### Types <a id="ios.types">[[ios.types]]</a>
216
 
217
+ ##### Class `ios_base::failure` <a id="ios.failure">[[ios.failure]]</a>
218
 
219
  ``` cpp
220
  namespace std {
221
  class ios_base::failure : public system_error {
222
  public:
 
228
 
229
  An implementation is permitted to define `ios_base::failure` as a
230
  synonym for a class with equivalent functionality to class
231
  `ios_base::failure` shown in this subclause.
232
 
233
+ [*Note 1*: When `ios_base::failure` is a synonym for another type, that
234
+ type is required to provide a nested type `failure` to emulate the
235
+ injected-class-name. — *end note*]
236
 
237
  The class `failure` defines the base class for the types of all objects
238
  thrown as exceptions, by functions in the iostreams library, to report
239
  errors detected during stream buffer operations.
240
 
 
251
 
252
  ``` cpp
253
  explicit failure(const string& msg, const error_code& ec = io_errc::stream);
254
  ```
255
 
256
+ *Effects:* Constructs the base class with `msg` and `ec`.
 
257
 
258
  ``` cpp
259
  explicit failure(const char* msg, const error_code& ec = io_errc::stream);
260
  ```
261
 
262
+ *Effects:* Constructs the base class with `msg` and `ec`.
 
263
 
264
+ ##### Type `ios_base::fmtflags` <a id="ios.fmtflags">[[ios.fmtflags]]</a>
265
 
266
  ``` cpp
267
  using fmtflags = T1;
268
  ```
269
 
270
+ The type `fmtflags` is a bitmask type [[bitmask.types]]. Setting its
271
+ elements has the effects indicated in [[ios.fmtflags]].
 
272
 
273
+ **Table: `fmtflags` effects** <a id="ios.fmtflags">[ios.fmtflags]</a>
274
 
275
  | Element | Effect(s) if set |
276
  | ------------ | --------------------------------------------------------------------------------------------------------------------------------------- |
277
  | `boolalpha` | insert and extract `bool` type in alphabetic format |
278
  | `dec` | converts integer input or generates integer output in decimal base |
 
290
  | `unitbuf` | flushes output after each output operation |
291
  | `uppercase` | replaces certain lowercase letters with their uppercase equivalents in generated output |
292
 
293
 
294
  Type `fmtflags` also defines the constants indicated in
295
+ [[ios.fmtflags.const]].
296
 
297
+ **Table: `fmtflags` constants** <a id="ios.fmtflags.const">[ios.fmtflags.const]</a>
298
 
299
  | Constant | Allowable values |
300
  | ------------- | ------------------------- |
301
  | `adjustfield` | `left | right | internal` |
302
  | `basefield` | `dec | oct | hex` |
303
  | `floatfield` | `scientific | fixed` |
304
 
305
 
306
+ ##### Type `ios_base::iostate` <a id="ios.iostate">[[ios.iostate]]</a>
307
 
308
  ``` cpp
309
  using iostate = T2;
310
  ```
311
 
312
+ The type `iostate` is a bitmask type [[bitmask.types]] that contains the
313
+ elements indicated in [[ios.iostate]].
314
 
315
+ **Table: `iostate` effects** <a id="ios.iostate">[ios.iostate]</a>
316
 
317
  | Element | Effect(s) if set |
318
  | --------- | ------------------------------------------------------------------------------------------------------------------------------------------------ |
319
  | `badbit` | indicates a loss of integrity in an input or output sequence (such as an irrecoverable read error from a file); |
320
  | `eofbit` | indicates that an input operation reached the end of an input sequence; |
 
323
 
324
  Type `iostate` also defines the constant:
325
 
326
  - `goodbit`, the value zero.
327
 
328
+ ##### Type `ios_base::openmode` <a id="ios.openmode">[[ios.openmode]]</a>
329
 
330
  ``` cpp
331
  using openmode = T3;
332
  ```
333
 
334
+ The type `openmode` is a bitmask type [[bitmask.types]]. It contains the
335
+ elements indicated in [[ios.openmode]].
336
 
337
+ **Table: `openmode` effects** <a id="ios.openmode">[ios.openmode]</a>
338
 
339
  | Element | Effect(s) if set |
340
  | -------- | ----------------------------------------------------------------- |
341
  | `app` | seek to end before each write |
342
  | `ate` | open and seek to end immediately after opening |
 
344
  | `in` | open for input |
345
  | `out` | open for output |
346
  | `trunc` | truncate an existing stream when opening |
347
 
348
 
349
+ ##### Type `ios_base::seekdir` <a id="ios.seekdir">[[ios.seekdir]]</a>
350
 
351
  ``` cpp
352
  using seekdir = T4;
353
  ```
354
 
355
+ The type `seekdir` is an enumerated type [[enumerated.types]] that
356
+ contains the elements indicated in [[ios.seekdir]].
 
357
 
358
+ **Table: `seekdir` effects** <a id="ios.seekdir">[ios.seekdir]</a>
359
 
360
  | Element | Meaning |
361
  | ------- | --------------------------------------------------------------------------------------- |
362
  | `beg` | request a seek (for subsequent input or output) relative to the beginning of the stream |
363
  | `cur` | request a seek relative to the current position within the sequence |
364
  | `end` | request a seek relative to the current end of the sequence |
365
 
366
 
367
+ ##### Class `ios_base::Init` <a id="ios.init">[[ios.init]]</a>
368
 
369
  ``` cpp
370
  namespace std {
371
  class ios_base::Init {
372
  public:
373
  Init();
374
+ Init(const Init&) = default;
375
  ~Init();
376
+ Init& operator=(const Init&) = default;
377
  private:
378
  static int init_cnt; // exposition only
379
  };
380
  }
381
  ```
382
 
383
  The class `Init` describes an object whose construction ensures the
384
+ construction of the eight objects declared in `<iostream>`
385
+ [[iostream.objects]] that associate file stream buffers with the
386
+ standard C streams provided for by the functions declared in `<cstdio>`.
 
387
 
388
  For the sake of exposition, the maintained data is presented here as:
389
 
390
  - `static int init_cnt`, counts the number of constructor and destructor
391
  calls for class `Init`, initialized to zero.
392
 
393
  ``` cpp
394
  Init();
395
  ```
396
 
397
+ *Effects:* Constructs and initializes the objects `cin`, `cout`, `cerr`,
398
+ `clog`, `wcin`, `wcout`, `wcerr`, and `wclog` if they have not already
399
+ been constructed and initialized.
 
400
 
401
  ``` cpp
402
  ~Init();
403
  ```
404
 
405
+ *Effects:* If there are no other instances of the class still in
406
+ existence, calls `cout.flush()`, `cerr.flush()`, `clog.flush()`,
407
+ `wcout.flush()`, `wcerr.flush()`, `wclog.flush()`.
 
408
 
409
+ #### State functions <a id="fmtflags.state">[[fmtflags.state]]</a>
410
 
411
  ``` cpp
412
  fmtflags flags() const;
413
  ```
414
 
 
416
 
417
  ``` cpp
418
  fmtflags flags(fmtflags fmtfl);
419
  ```
420
 
421
+ *Ensures:* `fmtfl == flags()`.
422
 
423
  *Returns:* The previous value of `flags()`.
424
 
425
  ``` cpp
426
  fmtflags setf(fmtflags fmtfl);
 
452
 
453
  ``` cpp
454
  streamsize precision(streamsize prec);
455
  ```
456
 
457
+ *Ensures:* `prec == precision()`.
458
 
459
  *Returns:* The previous value of `precision()`.
460
 
461
  ``` cpp
462
  streamsize width() const;
 
467
 
468
  ``` cpp
469
  streamsize width(streamsize wide);
470
  ```
471
 
472
+ *Ensures:* `wide == width()`.
473
 
474
  *Returns:* The previous value of `width()`.
475
 
476
+ #### Functions <a id="ios.base.locales">[[ios.base.locales]]</a>
477
 
478
  ``` cpp
479
  locale imbue(const locale& loc);
480
  ```
481
 
482
+ *Effects:* Calls each registered callback pair `(fn, idx)`
483
+ [[ios.base.callback]] as `(*fn)(imbue_event, *this, idx)` at such a time
484
+ that a call to `ios_base::getloc()` from within `fn` returns the new
485
+ locale value `loc`.
486
+
487
+ *Ensures:* `loc == getloc()`.
488
 
489
  *Returns:* The previous value of `getloc()`.
490
 
 
 
491
  ``` cpp
492
  locale getloc() const;
493
  ```
494
 
495
+ *Returns:* If no locale has been imbued, a copy of the global C++
496
+ locale, `locale()`, in effect at the time of construction. Otherwise,
497
+ returns the imbued locale, to be used to perform locale-dependent input
498
+ and output operations.
499
 
500
+ #### Static members <a id="ios.members.static">[[ios.members.static]]</a>
501
 
502
  ``` cpp
503
+ static bool sync_with_stdio(bool sync = true);
504
  ```
505
 
506
  *Returns:* `true` if the previous state of the standard iostream
507
+ objects [[iostream.objects]] was synchronized and otherwise returns
508
  `false`. The first time it is called, the function returns `true`.
509
 
510
  *Effects:* If any input or output operation has occurred using the
511
  standard streams prior to the call, the effect is
512
  *implementation-defined*. Otherwise, called with a `false` argument, it
 
552
  str.rdbuf()->sputbackc(c);
553
  ```
554
 
555
  for any sequence of characters.[^6]
556
 
557
+ #### Storage functions <a id="ios.base.storage">[[ios.base.storage]]</a>
558
 
559
  ``` cpp
560
  static int xalloc();
561
  ```
562
 
563
  *Returns:* `index` `++`.
564
 
565
+ *Remarks:* Concurrent access to this function by multiple threads does
566
+ not result in a data race [[intro.multithread]].
567
 
568
  ``` cpp
569
  long& iword(int idx);
570
  ```
571
 
572
+ *Preconditions:* `idx` is a value obtained by a call to `xalloc`.
573
+
574
  *Effects:* If `iarray` is a null pointer, allocates an array of `long`
575
  of unspecified size and stores a pointer to its first element in
576
  `iarray`. The function then extends the array pointed at by `iarray` as
577
  necessary to include the element `iarray[idx]`. Each newly allocated
578
  element of the array is initialized to zero. The reference returned is
 
589
 
590
  ``` cpp
591
  void*& pword(int idx);
592
  ```
593
 
594
+ *Preconditions:* `idx` is a value obtained by a call to `xalloc`.
595
+
596
  *Effects:* If `parray` is a null pointer, allocates an array of pointers
597
  to `void` of unspecified size and stores a pointer to its first element
598
  in `parray`. The function then extends the array pointed at by `parray`
599
  as necessary to include the element `parray[idx]`. Each newly allocated
600
  element of the array is initialized to a null pointer. The reference
 
610
  initialized to 0.
611
 
612
  *Remarks:* After a subsequent call to `pword(int)` for the same object,
613
  the earlier return value may no longer be valid.
614
 
615
+ #### Callbacks <a id="ios.base.callback">[[ios.base.callback]]</a>
616
 
617
  ``` cpp
618
+ void register_callback(event_callback fn, int idx);
619
  ```
620
 
621
+ *Preconditions:* The function `fn` does not throw exceptions.
 
 
 
 
 
622
 
623
+ *Effects:* Registers the pair `(fn, idx)` such that during calls to
624
+ `imbue()` [[ios.base.locales]], `copyfmt()`, or `~ios_base()`
625
+ [[ios.base.cons]], the function `fn` is called with argument `idx`.
626
+ Functions registered are called when an event occurs, in opposite order
627
+ of registration. Functions registered while a callback function is
628
+ active are not called until the next event.
629
 
630
  *Remarks:* Identical pairs are not merged. A function registered twice
631
  will be called twice.
632
 
633
+ #### Constructors and destructor <a id="ios.base.cons">[[ios.base.cons]]</a>
634
 
635
  ``` cpp
636
  ios_base();
637
  ```
638
 
 
643
 
644
  ``` cpp
645
  ~ios_base();
646
  ```
647
 
648
+ *Effects:* Calls each registered callback pair `(fn, idx)`
649
+ [[ios.base.callback]] as `(*fn)(erase_event, *this, idx)` at such time
650
+ that any `ios_base` member function called from within `fn` has
651
+ well-defined results.
652
 
653
  ### Class template `fpos` <a id="fpos">[[fpos]]</a>
654
 
655
  ``` cpp
656
  namespace std {
 
663
  stateT st; // exposition only
664
  };
665
  }
666
  ```
667
 
668
+ #### Members <a id="fpos.members">[[fpos.members]]</a>
669
 
670
  ``` cpp
671
  void state(stateT s);
672
  ```
673
 
 
677
  stateT state() const;
678
  ```
679
 
680
  *Returns:* Current value of `st`.
681
 
682
+ #### Requirements <a id="fpos.operations">[[fpos.operations]]</a>
683
 
684
+ An `fpos` type specifies file position information. It holds a state
685
+ object whose type is equal to the template parameter `stateT`. Type
686
+ `stateT` shall meet the *Cpp17DefaultConstructible* (
687
+ [[cpp17.defaultconstructible]]), *Cpp17CopyConstructible* (
688
+ [[cpp17.copyconstructible]]), *Cpp17CopyAssignable* (
689
+ [[cpp17.copyassignable]]), and *Cpp17Destructible* (
690
+ [[cpp17.destructible]]) requirements. If
691
+ `is_trivially_copy_constructible_v<stateT>` is `true`, then
692
+ `fpos<stateT>` has a trivial copy constructor. If
693
+ `is_trivially_copy_assignable<stateT>` is `true`, then `fpos<stateT>`
694
+ has a trivial copy assignment operator. If
695
+ `is_trivially_destructible_v<stateT>` is `true`, then `fpos<stateT>` has
696
+ a trivial destructor. All specializations of `fpos` meet the
697
+ *Cpp17DefaultConstructible*, *Cpp17CopyConstructible*,
698
+ *Cpp17CopyAssignable*, *Cpp17Destructible*, and
699
+ *Cpp17EqualityComparable* ([[cpp17.equalitycomparable]]) requirements.
700
+ In addition, the expressions shown in [[fpos.operations]] are valid and
701
+ have the indicated semantics. In that table,
702
 
703
  - `P` refers to an instance of `fpos`,
704
+ - `p` and `q` refer to values of type `P` or `const P`,
705
+ - `pl` and `ql` refer to modifiable lvalues of type `P`,
706
+ - `O` refers to type `streamoff`, and
707
+ - `o` refers to a value of type `streamoff` or `const streamoff`.
 
 
 
 
 
 
 
708
 
709
  Stream operations that return a value of type `traits::pos_type` return
710
  `P(O(-1))` as an invalid value to signal an error. If this value is used
711
  as an argument to any `istream`, `ostream`, or `streambuf` member that
712
  accepts a value of type `traits::pos_type` then the behavior of that
 
775
 
776
  };
777
  }
778
  ```
779
 
780
+ #### Constructors <a id="basic.ios.cons">[[basic.ios.cons]]</a>
781
 
782
  ``` cpp
783
  explicit basic_ios(basic_streambuf<charT, traits>* sb);
784
  ```
785
 
786
+ *Effects:* Assigns initial values to its member objects by calling
787
+ `init(sb)`.
788
 
789
  ``` cpp
790
  basic_ios();
791
  ```
792
 
793
+ *Effects:* Leaves its member objects uninitialized. The object shall be
794
+ initialized by calling `basic_ios::init` before its first use or before
795
+ it is destroyed, whichever comes first; otherwise the behavior is
796
+ undefined.
 
797
 
798
  ``` cpp
799
  ~basic_ios();
800
  ```
801
 
 
803
 
804
  ``` cpp
805
  void init(basic_streambuf<charT, traits>* sb);
806
  ```
807
 
808
+ *Ensures:* The postconditions of this function are indicated in
809
+ [[basic.ios.cons]].
810
 
811
+ **Table: `basic_ios::init()` effects** <a id="basic.ios.cons">[basic.ios.cons]</a>
812
 
813
  | Element | Value |
814
  | -------------- | ------------------------------------------------------------ |
815
  | `rdbuf()` | `sb` |
816
  | `tie()` | `0` |
 
836
 
837
  ``` cpp
838
  basic_ostream<charT, traits>* tie(basic_ostream<charT, traits>* tiestr);
839
  ```
840
 
841
+ *Preconditions:* If `tiestr` is not null, `tiestr` is not reachable by
842
  traversing the linked list of tied stream objects starting from
843
  `tiestr->tie()`.
844
 
845
+ *Ensures:* `tiestr == tie()`.
846
 
847
  *Returns:* The previous value of `tie()`.
848
 
849
  ``` cpp
850
  basic_streambuf<charT, traits>* rdbuf() const;
 
854
 
855
  ``` cpp
856
  basic_streambuf<charT, traits>* rdbuf(basic_streambuf<charT, traits>* sb);
857
  ```
858
 
 
 
859
  *Effects:* Calls `clear()`.
860
 
861
+ *Ensures:* `sb == rdbuf()`.
862
+
863
  *Returns:* The previous value of `rdbuf()`.
864
 
865
  ``` cpp
866
  locale imbue(const locale& loc);
867
  ```
868
 
869
+ *Effects:* Calls `ios_base::imbue(loc)` [[ios.base.locales]] and if
870
+ `rdbuf() != 0` then `rdbuf()->pubimbue(loc)` [[streambuf.locales]].
871
 
872
  *Returns:* The prior value of `ios_base::imbue()`.
873
 
874
  ``` cpp
875
  char narrow(char_type c, char dfault) const;
 
892
 
893
  ``` cpp
894
  char_type fill(char_type fillch);
895
  ```
896
 
897
+ *Ensures:* `traits::eq(fillch, fill())`.
898
 
899
  *Returns:* The previous value of `fill()`.
900
 
901
  ``` cpp
902
  basic_ios& copyfmt(const basic_ios& rhs);
903
  ```
904
 
905
+ *Effects:* If `(this == addressof(rhs))` is `true` does nothing.
906
+ Otherwise assigns to the member objects of `*this` the corresponding
907
+ member objects of `rhs` as follows:
908
 
909
+ - calls each registered callback pair `(fn, idx)` as
910
+ `(*fn)(erase_event, *this, idx)`;
911
+ - then, assigns to the member objects of `*this` the corresponding
912
+ member objects of `rhs`, except that
913
  - `rdstate()`, `rdbuf()`, and `exceptions()` are left unchanged;
914
+ - the contents of arrays pointed at by `pword` and `iword` are copied,
915
+ not the pointers themselves;[^10] and
916
  - if any newly stored pointer values in `*this` point at objects
917
+ stored outside the object `rhs` and those objects are destroyed when
918
+ `rhs` is destroyed, the newly stored pointer values are altered to
919
+ point at newly constructed copies of the objects;
920
+ - then, calls each callback pair that was copied from `rhs` as
921
+ `(*fn)(copyfmt_event, *this, idx)`;
922
+ - then, calls `exceptions(rhs.exceptions())`.
923
 
924
  [*Note 1*: The second pass through the callback pairs permits a copied
925
  `pword` value to be zeroed, or to have its referent deep copied or
926
  reference counted, or to have other special action taken. — *end note*]
927
 
928
+ *Ensures:* The postconditions of this function are indicated in
929
+ [[basic.ios.copyfmt]].
930
 
931
+ **Table: `basic_ios::copyfmt()` effects** <a id="basic.ios.copyfmt">[basic.ios.copyfmt]</a>
932
 
933
  | Element | Value |
934
  | -------------- | ------------------ |
935
  | `rdbuf()` | unchanged |
936
  | `tie()` | `rhs.tie()` |
 
948
  ``` cpp
949
  void move(basic_ios& rhs);
950
  void move(basic_ios&& rhs);
951
  ```
952
 
953
+ *Ensures:* `*this` has the state that `rhs` had before the function
954
+ call, except that `rdbuf()` returns `nullptr`. `rhs` is in a valid but
955
+ unspecified state, except that `rhs.rdbuf()` returns the same value as
956
+ it returned before the function call, and `rhs.tie()` returns `nullptr`.
 
957
 
958
  ``` cpp
959
  void swap(basic_ios& rhs) noexcept;
960
  ```
961
 
962
+ *Effects:* The states of `*this` and `rhs` are exchanged, except that
963
+ `rdbuf()` returns the same value as it returned before the function
964
+ call, and `rhs.rdbuf()` returns the same value as it returned before the
965
+ function call.
966
 
967
  ``` cpp
968
  void set_rdbuf(basic_streambuf<charT, traits>* sb);
969
  ```
970
 
971
+ *Preconditions:* `sb != nullptr` is `true`.
972
 
973
  *Effects:* Associates the `basic_streambuf` object pointed to by `sb`
974
  with this stream without calling `clear()`.
975
 
976
+ *Ensures:* `rdbuf() == sb` is `true`.
977
 
978
  *Throws:* Nothing.
979
 
980
+ #### Flags functions <a id="iostate.flags">[[iostate.flags]]</a>
981
 
982
  ``` cpp
983
  explicit operator bool() const;
984
  ```
985
 
 
999
 
1000
  ``` cpp
1001
  void clear(iostate state = goodbit);
1002
  ```
1003
 
1004
+ *Ensures:* If `rdbuf() != 0` then `state == rdstate()`; otherwise
1005
  `rdstate() == (state | ios_base::badbit)`.
1006
 
1007
  *Effects:* If
1008
  `((state | (rdbuf() ? goodbit : badbit)) & exceptions()) == 0`, returns.
1009
+ Otherwise, the function throws an object of class `ios_base::failure`
1010
+ [[ios.failure]], constructed with *implementation-defined* argument
1011
+ values.
1012
 
1013
  ``` cpp
1014
  void setstate(iostate state);
1015
  ```
1016
 
1017
  *Effects:* Calls `clear(rdstate() | state)` (which may throw
1018
+ `ios_base::failure` [[ios.failure]]).
1019
 
1020
  ``` cpp
1021
  bool good() const;
1022
  ```
1023
 
 
1050
 
1051
  ``` cpp
1052
  void exceptions(iostate except);
1053
  ```
1054
 
1055
+ *Ensures:* `except == exceptions()`.
1056
 
1057
  *Effects:* Calls `clear(rdstate())`.
1058
 
1059
  ### `ios_base` manipulators <a id="std.ios.manip">[[std.ios.manip]]</a>
1060
 
1061
  #### `fmtflags` manipulators <a id="fmtflags.manip">[[fmtflags.manip]]</a>
1062
 
1063
+ Each function specified in this subclause is a designated addressable
1064
+ function [[namespace.std]].
1065
+
1066
  ``` cpp
1067
  ios_base& boolalpha(ios_base& str);
1068
  ```
1069
 
1070
  *Effects:* Calls `str.setf(ios_base::boolalpha)`.
 
1175
 
1176
  *Returns:* `str`.
1177
 
1178
  #### `adjustfield` manipulators <a id="adjustfield.manip">[[adjustfield.manip]]</a>
1179
 
1180
+ Each function specified in this subclause is a designated addressable
1181
+ function [[namespace.std]].
1182
+
1183
  ``` cpp
1184
  ios_base& internal(ios_base& str);
1185
  ```
1186
 
1187
  *Effects:* Calls `str.setf(ios_base::internal, ios_base::adjustfield)`.
 
1204
 
1205
  *Returns:* `str`.
1206
 
1207
  #### `basefield` manipulators <a id="basefield.manip">[[basefield.manip]]</a>
1208
 
1209
+ Each function specified in this subclause is a designated addressable
1210
+ function [[namespace.std]].
1211
+
1212
  ``` cpp
1213
  ios_base& dec(ios_base& str);
1214
  ```
1215
 
1216
  *Effects:* Calls `str.setf(ios_base::dec, ios_base::basefield)`.
 
1233
 
1234
  *Returns:* `str`.
1235
 
1236
  #### `floatfield` manipulators <a id="floatfield.manip">[[floatfield.manip]]</a>
1237
 
1238
+ Each function specified in this subclause is a designated addressable
1239
+ function [[namespace.std]].
1240
+
1241
  ``` cpp
1242
  ios_base& fixed(ios_base& str);
1243
  ```
1244
 
1245
  *Effects:* Calls `str.setf(ios_base::fixed, ios_base::floatfield)`.
 
1263
 
1264
  *Returns:* `str`.
1265
 
1266
  [*Note 1*: The more obvious use of `ios_base::hex` to specify
1267
  hexadecimal floating-point format would change the meaning of existing
1268
+ well-defined programs. C++03 gives no meaning to the combination of
1269
  `fixed` and `scientific`. — *end note*]
1270
 
1271
  ``` cpp
1272
  ios_base& defaultfloat(ios_base& str);
1273
  ```
1274
 
1275
  *Effects:* Calls `str.unsetf(ios_base::floatfield)`.
1276
 
1277
  *Returns:* `str`.
1278
 
1279
+ ### Error reporting <a id="error.reporting">[[error.reporting]]</a>
1280
 
1281
  ``` cpp
1282
  error_code make_error_code(io_errc e) noexcept;
1283
  ```
1284