tmp/tmpy865wxwx/{from.md → to.md}
RENAMED
|
@@ -1,22 +1,22 @@
|
|
| 1 |
## Iostreams base classes <a id="iostreams.base">[[iostreams.base]]</a>
|
| 2 |
|
| 3 |
-
###
|
| 4 |
|
| 5 |
``` cpp
|
| 6 |
-
#include <iosfwd>
|
| 7 |
|
| 8 |
namespace std {
|
| 9 |
-
|
| 10 |
-
|
| 11 |
template <class stateT> class fpos;
|
| 12 |
|
| 13 |
class ios_base;
|
| 14 |
template <class charT, class traits = char_traits<charT>>
|
| 15 |
class basic_ios;
|
| 16 |
|
| 17 |
-
// [std.ios.manip], manipulators
|
| 18 |
ios_base& boolalpha (ios_base& str);
|
| 19 |
ios_base& noboolalpha(ios_base& str);
|
| 20 |
|
| 21 |
ios_base& showbase (ios_base& str);
|
| 22 |
ios_base& noshowbase (ios_base& str);
|
|
@@ -34,27 +34,27 @@ namespace std {
|
|
| 34 |
ios_base& nouppercase(ios_base& str);
|
| 35 |
|
| 36 |
ios_base& unitbuf (ios_base& str);
|
| 37 |
ios_base& nounitbuf (ios_base& str);
|
| 38 |
|
| 39 |
-
// [adjustfield.manip] adjustfield
|
| 40 |
ios_base& internal (ios_base& str);
|
| 41 |
ios_base& left (ios_base& str);
|
| 42 |
ios_base& right (ios_base& str);
|
| 43 |
|
| 44 |
-
// [basefield.manip] basefield
|
| 45 |
ios_base& dec (ios_base& str);
|
| 46 |
ios_base& hex (ios_base& str);
|
| 47 |
ios_base& oct (ios_base& str);
|
| 48 |
|
| 49 |
-
// [floatfield.manip] floatfield
|
| 50 |
ios_base& fixed (ios_base& str);
|
| 51 |
ios_base& scientific (ios_base& str);
|
| 52 |
ios_base& hexfloat (ios_base& str);
|
| 53 |
ios_base& defaultfloat(ios_base& str);
|
| 54 |
|
| 55 |
-
// [error.reporting] error reporting
|
| 56 |
enum class io_errc {
|
| 57 |
stream = 1
|
| 58 |
};
|
| 59 |
|
| 60 |
template <> struct is_error_code_enum<io_errc> : public true_type { };
|
|
@@ -65,19 +65,19 @@ namespace std {
|
|
| 65 |
```
|
| 66 |
|
| 67 |
### Types <a id="stream.types">[[stream.types]]</a>
|
| 68 |
|
| 69 |
``` cpp
|
| 70 |
-
|
| 71 |
```
|
| 72 |
|
| 73 |
The type `streamoff` is a synonym for one of the signed basic integral
|
| 74 |
types of sufficient size to represent the maximum possible file size for
|
| 75 |
the operating system.[^4]
|
| 76 |
|
| 77 |
``` cpp
|
| 78 |
-
|
| 79 |
```
|
| 80 |
|
| 81 |
The type `streamsize` is a synonym for one of the signed basic integral
|
| 82 |
types. It is used to represent the number of characters transferred in
|
| 83 |
an I/O operation, or the size of I/O buffers.[^5]
|
|
@@ -86,14 +86,14 @@ an I/O operation, or the size of I/O buffers.[^5]
|
|
| 86 |
|
| 87 |
``` cpp
|
| 88 |
namespace std {
|
| 89 |
class ios_base {
|
| 90 |
public:
|
| 91 |
-
class failure;
|
| 92 |
|
| 93 |
-
// [ios::fmtflags] fmtflags
|
| 94 |
-
|
| 95 |
static constexpr fmtflags boolalpha = unspecified;
|
| 96 |
static constexpr fmtflags dec = unspecified;
|
| 97 |
static constexpr fmtflags fixed = unspecified;
|
| 98 |
static constexpr fmtflags hex = unspecified;
|
| 99 |
static constexpr fmtflags internal = unspecified;
|
|
@@ -109,35 +109,35 @@ 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 |
-
|
| 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 |
-
|
| 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 |
-
|
| 132 |
static constexpr seekdir beg = unspecified;
|
| 133 |
static constexpr seekdir cur = unspecified;
|
| 134 |
static constexpr seekdir end = unspecified;
|
| 135 |
|
| 136 |
class Init;
|
| 137 |
|
| 138 |
-
// [fmtflags.state] fmtflags state
|
| 139 |
fmtflags flags() const;
|
| 140 |
fmtflags flags(fmtflags fmtfl);
|
| 141 |
fmtflags setf(fmtflags fmtfl);
|
| 142 |
fmtflags setf(fmtflags fmtfl, fmtflags mask);
|
| 143 |
void unsetf(fmtflags mask);
|
|
@@ -145,25 +145,25 @@ namespace std {
|
|
| 145 |
streamsize precision() const;
|
| 146 |
streamsize precision(streamsize prec);
|
| 147 |
streamsize width() const;
|
| 148 |
streamsize width(streamsize wide);
|
| 149 |
|
| 150 |
-
// [ios.base.locales] locales
|
| 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 |
-
|
| 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 |
|
|
@@ -182,11 +182,12 @@ namespace std {
|
|
| 182 |
|
| 183 |
`ios_base`
|
| 184 |
|
| 185 |
defines several member types:
|
| 186 |
|
| 187 |
-
- a
|
|
|
|
| 188 |
- a class `Init`;
|
| 189 |
- three bitmask types, `fmtflags`, `iostate`, and `openmode`;
|
| 190 |
- an enumerated type, `seekdir`.
|
| 191 |
|
| 192 |
It maintains several kinds of data:
|
|
@@ -195,20 +196,24 @@ It maintains several kinds of data:
|
|
| 195 |
- control information that influences how to interpret (format) input
|
| 196 |
sequences and how to generate (format) output sequences;
|
| 197 |
- additional information that is stored by the program for its private
|
| 198 |
use.
|
| 199 |
|
|
|
|
|
|
|
| 200 |
For the sake of exposition, the maintained data is presented here as:
|
| 201 |
|
| 202 |
- `static int index`, specifies the next available unique index for the
|
| 203 |
integer or pointer arrays maintained for the private use of the
|
| 204 |
program, initialized to an unspecified value;
|
| 205 |
- `long* iarray`, points to the first element of an arbitrary-length
|
| 206 |
`long` array maintained for the private use of the program;
|
| 207 |
- `void** parray`, points to the first element of an arbitrary-length
|
| 208 |
pointer array maintained for the private use of the program.
|
| 209 |
|
|
|
|
|
|
|
| 210 |
#### Types <a id="ios.types">[[ios.types]]</a>
|
| 211 |
|
| 212 |
##### Class `ios_base::failure` <a id="ios::failure">[[ios::failure]]</a>
|
| 213 |
|
| 214 |
``` cpp
|
|
@@ -219,22 +224,32 @@ namespace std {
|
|
| 219 |
explicit failure(const char* msg, const error_code& ec = io_errc::stream);
|
| 220 |
};
|
| 221 |
}
|
| 222 |
```
|
| 223 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 224 |
The class `failure` defines the base class for the types of all objects
|
| 225 |
thrown as exceptions, by functions in the iostreams library, to report
|
| 226 |
errors detected during stream buffer operations.
|
| 227 |
|
| 228 |
When throwing `ios_base::failure` exceptions, implementations should
|
| 229 |
provide values of `ec` that identify the specific reason for the
|
| 230 |
-
failure.
|
|
|
|
|
|
|
| 231 |
reported as `system_category()` errors with an error value of the error
|
| 232 |
number reported by the operating system. Errors arising from within the
|
| 233 |
stream library would typically be reported as
|
| 234 |
`error_code(io_errc::stream,
|
| 235 |
-
iostream_category())`.
|
| 236 |
|
| 237 |
``` cpp
|
| 238 |
explicit failure(const string& msg, const error_code& ec = io_errc::stream);
|
| 239 |
```
|
| 240 |
|
|
@@ -249,11 +264,11 @@ explicit failure(const char* msg, const error_code& ec = io_errc::stream);
|
|
| 249 |
base class with `msg` and `ec`.
|
| 250 |
|
| 251 |
##### Type `ios_base::fmtflags` <a id="ios::fmtflags">[[ios::fmtflags]]</a>
|
| 252 |
|
| 253 |
``` cpp
|
| 254 |
-
|
| 255 |
```
|
| 256 |
|
| 257 |
The type `fmtflags` is a bitmask type ([[bitmask.types]]). Setting its
|
| 258 |
elements has the effects indicated in
|
| 259 |
Table [[tab:iostreams.fmtflags.effects]].
|
|
@@ -292,11 +307,11 @@ Table [[tab:iostreams.fmtflags.constants]].
|
|
| 292 |
|
| 293 |
|
| 294 |
##### Type `ios_base::iostate` <a id="ios::iostate">[[ios::iostate]]</a>
|
| 295 |
|
| 296 |
``` cpp
|
| 297 |
-
|
| 298 |
```
|
| 299 |
|
| 300 |
The type `iostate` is a bitmask type ([[bitmask.types]]) that contains
|
| 301 |
the elements indicated in Table [[tab:iostreams.iostate.effects]].
|
| 302 |
|
|
@@ -314,11 +329,11 @@ Type `iostate` also defines the constant:
|
|
| 314 |
- `goodbit`, the value zero.
|
| 315 |
|
| 316 |
##### Type `ios_base::openmode` <a id="ios::openmode">[[ios::openmode]]</a>
|
| 317 |
|
| 318 |
``` cpp
|
| 319 |
-
|
| 320 |
```
|
| 321 |
|
| 322 |
The type `openmode` is a bitmask type ([[bitmask.types]]). It contains
|
| 323 |
the elements indicated in Table [[tab:iostreams.openmode.effects]].
|
| 324 |
|
|
@@ -335,11 +350,11 @@ the elements indicated in Table [[tab:iostreams.openmode.effects]].
|
|
| 335 |
|
| 336 |
|
| 337 |
##### Type `ios_base::seekdir` <a id="ios::seekdir">[[ios::seekdir]]</a>
|
| 338 |
|
| 339 |
``` cpp
|
| 340 |
-
|
| 341 |
```
|
| 342 |
|
| 343 |
The type `seekdir` is an enumerated type ([[enumerated.types]]) that
|
| 344 |
contains the elements indicated in
|
| 345 |
Table [[tab:iostreams.seekdir.effects]].
|
|
@@ -369,11 +384,11 @@ namespace std {
|
|
| 369 |
|
| 370 |
The class `Init` describes an object whose construction ensures the
|
| 371 |
construction of the eight objects declared in `<iostream>` (
|
| 372 |
[[iostream.objects]]) that associate file stream buffers with the
|
| 373 |
standard C streams provided for by the functions declared in
|
| 374 |
-
`<cstdio>` ([[
|
| 375 |
|
| 376 |
For the sake of exposition, the maintained data is presented here as:
|
| 377 |
|
| 378 |
- `static int init_cnt`, counts the number of constructor and destructor
|
| 379 |
calls for class `Init`, initialized to zero.
|
|
@@ -406,11 +421,11 @@ fmtflags flags() const;
|
|
| 406 |
|
| 407 |
``` cpp
|
| 408 |
fmtflags flags(fmtflags fmtfl);
|
| 409 |
```
|
| 410 |
|
| 411 |
-
`fmtfl == flags()`.
|
| 412 |
|
| 413 |
*Returns:* The previous value of `flags()`.
|
| 414 |
|
| 415 |
``` cpp
|
| 416 |
fmtflags setf(fmtflags fmtfl);
|
|
@@ -442,11 +457,11 @@ streamsize precision() const;
|
|
| 442 |
|
| 443 |
``` cpp
|
| 444 |
streamsize precision(streamsize prec);
|
| 445 |
```
|
| 446 |
|
| 447 |
-
`prec == precision()`.
|
| 448 |
|
| 449 |
*Returns:* The previous value of `precision()`.
|
| 450 |
|
| 451 |
``` cpp
|
| 452 |
streamsize width() const;
|
|
@@ -457,11 +472,11 @@ certain output conversions.
|
|
| 457 |
|
| 458 |
``` cpp
|
| 459 |
streamsize width(streamsize wide);
|
| 460 |
```
|
| 461 |
|
| 462 |
-
`wide == width()`.
|
| 463 |
|
| 464 |
*Returns:* The previous value of `width()`.
|
| 465 |
|
| 466 |
#### `ios_base` functions <a id="ios.base.locales">[[ios.base.locales]]</a>
|
| 467 |
|
|
@@ -475,11 +490,11 @@ locale imbue(const locale& loc);
|
|
| 475 |
`ios_base::getloc()` from within `fn` returns the new locale value
|
| 476 |
`loc`.
|
| 477 |
|
| 478 |
*Returns:* The previous value of `getloc()`.
|
| 479 |
|
| 480 |
-
`loc == getloc()`.
|
| 481 |
|
| 482 |
``` cpp
|
| 483 |
locale getloc() const;
|
| 484 |
```
|
| 485 |
|
|
@@ -498,11 +513,11 @@ bool sync_with_stdio(bool sync = true);
|
|
| 498 |
objects ([[iostream.objects]]) was synchronized and otherwise returns
|
| 499 |
`false`. The first time it is called, the function returns `true`.
|
| 500 |
|
| 501 |
*Effects:* If any input or output operation has occurred using the
|
| 502 |
standard streams prior to the call, the effect is
|
| 503 |
-
*implementation-defined*. Otherwise, called with a false argument, it
|
| 504 |
allows the standard streams to operate independently of the standard C
|
| 505 |
streams.
|
| 506 |
|
| 507 |
When a standard iostream object `str` is *synchronized* with a standard
|
| 508 |
stdio stream `f`, the effect of inserting a character `c` by
|
|
@@ -566,11 +581,11 @@ of unspecified size and stores a pointer to its first element in
|
|
| 566 |
necessary to include the element `iarray[idx]`. Each newly allocated
|
| 567 |
element of the array is initialized to zero. The reference returned is
|
| 568 |
invalid after any other operations on the object.[^7] However, the value
|
| 569 |
of the storage referred to is retained, so that until the next call to
|
| 570 |
`copyfmt`, calling `iword` with the same index yields another reference
|
| 571 |
-
to the same value. If the function fails[^8] and `*this` is a base
|
| 572 |
subobject of a `basic_ios<>` object or subobject, the effect is
|
| 573 |
equivalent to calling `basic_ios<>::setstate(badbit)` on the derived
|
| 574 |
object (which may throw `failure`).
|
| 575 |
|
| 576 |
*Returns:* On success `iarray[idx]`. On failure, a valid `long&`
|
|
@@ -587,12 +602,12 @@ as necessary to include the element `parray[idx]`. Each newly allocated
|
|
| 587 |
element of the array is initialized to a null pointer. The reference
|
| 588 |
returned is invalid after any other operations on the object. However,
|
| 589 |
the value of the storage referred to is retained, so that until the next
|
| 590 |
call to `copyfmt`, calling `pword` with the same index yields another
|
| 591 |
reference to the same value. If the function fails[^9] and `*this` is a
|
| 592 |
-
base subobject of a `basic_ios<>` object or subobject, the effect
|
| 593 |
-
equivalent to calling `basic_ios<>::setstate(badbit)` on the derived
|
| 594 |
object (which may throw `failure`).
|
| 595 |
|
| 596 |
*Returns:* On success `parray[idx]`. On failure a valid `void*&`
|
| 597 |
initialized to 0.
|
| 598 |
|
|
@@ -641,11 +656,11 @@ member function called from within `fn` has well defined results.
|
|
| 641 |
|
| 642 |
``` cpp
|
| 643 |
namespace std {
|
| 644 |
template <class stateT> class fpos {
|
| 645 |
public:
|
| 646 |
-
// [fpos.members]
|
| 647 |
stateT state() const;
|
| 648 |
void state(stateT);
|
| 649 |
private;
|
| 650 |
stateT st; // exposition only
|
| 651 |
};
|
|
@@ -656,11 +671,11 @@ namespace std {
|
|
| 656 |
|
| 657 |
``` cpp
|
| 658 |
void state(stateT s);
|
| 659 |
```
|
| 660 |
|
| 661 |
-
*Effects:*
|
| 662 |
|
| 663 |
``` cpp
|
| 664 |
stateT state() const;
|
| 665 |
```
|
| 666 |
|
|
@@ -676,14 +691,15 @@ are permitted. In that table,
|
|
| 676 |
- `O` refers to type `streamoff`,
|
| 677 |
- `o` refers to a value of type `streamoff`,
|
| 678 |
- `sz` refers to a value of type `streamsize` and
|
| 679 |
- `i` refers to a value of type `int`.
|
| 680 |
|
| 681 |
-
Every implementation is required to supply overloaded
|
| 682 |
-
`fpos` objects to satisfy the requirements of
|
| 683 |
-
is unspecified whether these operators are
|
| 684 |
-
operators, or provided in some other
|
|
|
|
| 685 |
|
| 686 |
Stream operations that return a value of type `traits::pos_type` return
|
| 687 |
`P(O(-1))` as an invalid value to signal an error. If this value is used
|
| 688 |
as an argument to any `istream`, `ostream`, or `streambuf` member that
|
| 689 |
accepts a value of type `traits::pos_type` then the behavior of that
|
|
@@ -696,18 +712,17 @@ function is undefined.
|
|
| 696 |
``` cpp
|
| 697 |
namespace std {
|
| 698 |
template <class charT, class traits = char_traits<charT>>
|
| 699 |
class basic_ios : public ios_base {
|
| 700 |
public:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 701 |
|
| 702 |
-
//
|
| 703 |
-
typedef charT char_type;
|
| 704 |
-
typedef typename traits::int_type int_type;
|
| 705 |
-
typedef typename traits::pos_type pos_type;
|
| 706 |
-
typedef typename traits::off_type off_type;
|
| 707 |
-
typedef traits traits_type;
|
| 708 |
-
|
| 709 |
explicit operator bool() const;
|
| 710 |
bool operator!() const;
|
| 711 |
iostate rdstate() const;
|
| 712 |
void clear(iostate state = goodbit);
|
| 713 |
void setstate(iostate state);
|
|
@@ -717,15 +732,15 @@ namespace std {
|
|
| 717 |
bool bad() const;
|
| 718 |
|
| 719 |
iostate exceptions() const;
|
| 720 |
void exceptions(iostate except);
|
| 721 |
|
| 722 |
-
// [basic.ios.cons]
|
| 723 |
explicit basic_ios(basic_streambuf<charT, traits>* sb);
|
| 724 |
virtual ~basic_ios();
|
| 725 |
|
| 726 |
-
// [basic.ios.members]
|
| 727 |
basic_ostream<charT, traits>* tie() const;
|
| 728 |
basic_ostream<charT, traits>* tie(basic_ostream<charT, traits>* tiestr);
|
| 729 |
|
| 730 |
basic_streambuf<charT, traits>* rdbuf() const;
|
| 731 |
basic_streambuf<charT, traits>* rdbuf(basic_streambuf<charT, traits>* sb);
|
|
@@ -796,11 +811,11 @@ Table [[tab:iostreams.basicios.init.effects]].
|
|
| 796 |
| `rdstate()` | `goodbit` if `sb` is not a null pointer, otherwise `badbit`. |
|
| 797 |
| `exceptions()` | `goodbit` |
|
| 798 |
| `flags()` | `skipws | dec` |
|
| 799 |
| `width()` | `0` |
|
| 800 |
| `precision()` | `6` |
|
| 801 |
-
| `fill()` | `widen(' ')
|
| 802 |
| `getloc()` | a copy of the value returned by `locale()` |
|
| 803 |
| `iarray` | a null pointer |
|
| 804 |
| `parray` | a null pointer |
|
| 805 |
|
| 806 |
|
|
@@ -819,11 +834,11 @@ basic_ostream<charT,traits>* tie(basic_ostream<charT,traits>* tiestr);
|
|
| 819 |
|
| 820 |
*Requires:* If `tiestr` is not null, `tiestr` must not be reachable by
|
| 821 |
traversing the linked list of tied stream objects starting from
|
| 822 |
`tiestr->tie()`.
|
| 823 |
|
| 824 |
-
`tiestr == tie()`.
|
| 825 |
|
| 826 |
*Returns:* The previous value of `tie()`.
|
| 827 |
|
| 828 |
``` cpp
|
| 829 |
basic_streambuf<charT, traits>* rdbuf() const;
|
|
@@ -833,11 +848,11 @@ basic_streambuf<charT,traits>* rdbuf() const;
|
|
| 833 |
|
| 834 |
``` cpp
|
| 835 |
basic_streambuf<charT, traits>* rdbuf(basic_streambuf<charT, traits>* sb);
|
| 836 |
```
|
| 837 |
|
| 838 |
-
`sb == rdbuf()`.
|
| 839 |
|
| 840 |
*Effects:* Calls `clear()`.
|
| 841 |
|
| 842 |
*Returns:* The previous value of `rdbuf()`.
|
| 843 |
|
|
@@ -871,11 +886,11 @@ specified field width.
|
|
| 871 |
|
| 872 |
``` cpp
|
| 873 |
char_type fill(char_type fillch);
|
| 874 |
```
|
| 875 |
|
| 876 |
-
`traits::eq(fillch, fill())`
|
| 877 |
|
| 878 |
*Returns:* The previous value of `fill()`.
|
| 879 |
|
| 880 |
``` cpp
|
| 881 |
basic_ios& copyfmt(const basic_ios& rhs);
|
|
@@ -896,15 +911,15 @@ follows:
|
|
| 896 |
stored outside the object `rhs` and those objects are destroyed
|
| 897 |
when `rhs` is destroyed, the newly stored pointer values are
|
| 898 |
altered to point at newly constructed copies of the objects;
|
| 899 |
3. calls each callback pair that was copied from `rhs` as
|
| 900 |
`(*fn)(copyfmt_event, *this, index)`;
|
| 901 |
-
4. calls `exceptions(rhs.
|
| 902 |
|
| 903 |
-
*Note
|
| 904 |
`pword` value to be zeroed, or to have its referent deep copied or
|
| 905 |
-
reference counted, or to have other special action taken.
|
| 906 |
|
| 907 |
*Postconditions:* The postconditions of this function are indicated in
|
| 908 |
Table [[tab:iostreams.copyfmt.effects]].
|
| 909 |
|
| 910 |
**Table: `basic_ios::copyfmt()` effects** <a id="tab:iostreams.copyfmt.effects">[tab:iostreams.copyfmt.effects]</a>
|
|
@@ -979,16 +994,16 @@ iostate rdstate() const;
|
|
| 979 |
|
| 980 |
``` cpp
|
| 981 |
void clear(iostate state = goodbit);
|
| 982 |
```
|
| 983 |
|
| 984 |
-
If `rdbuf()!=0` then `state == rdstate()`; otherwise
|
| 985 |
`rdstate() == (state | ios_base::badbit)`.
|
| 986 |
|
| 987 |
*Effects:* If
|
| 988 |
`((state | (rdbuf() ? goodbit : badbit)) & exceptions()) == 0`, returns.
|
| 989 |
-
Otherwise, the function throws an object
|
| 990 |
`basic_ios::failure` ([[ios::failure]]), constructed with
|
| 991 |
*implementation-defined* argument values.
|
| 992 |
|
| 993 |
``` cpp
|
| 994 |
void setstate(iostate state);
|
|
@@ -1030,11 +1045,11 @@ exceptions to be thrown.
|
|
| 1030 |
|
| 1031 |
``` cpp
|
| 1032 |
void exceptions(iostate except);
|
| 1033 |
```
|
| 1034 |
|
| 1035 |
-
`except == exceptions()`.
|
| 1036 |
|
| 1037 |
*Effects:* Calls `clear(rdstate())`.
|
| 1038 |
|
| 1039 |
### `ios_base` manipulators <a id="std.ios.manip">[[std.ios.manip]]</a>
|
| 1040 |
|
|
@@ -1229,14 +1244,14 @@ ios_base& hexfloat(ios_base& str);
|
|
| 1229 |
*Effects:* Calls
|
| 1230 |
`str.setf(ios_base::fixed | ios_base::scientific, ios_base::floatfield)`.
|
| 1231 |
|
| 1232 |
*Returns:* `str`.
|
| 1233 |
|
| 1234 |
-
The more obvious use of `ios_base::hex` to specify
|
| 1235 |
-
floating-point format would change the meaning of existing
|
| 1236 |
-
programs. C++
|
| 1237 |
-
`scientific`.
|
| 1238 |
|
| 1239 |
``` cpp
|
| 1240 |
ios_base& defaultfloat(ios_base& str);
|
| 1241 |
```
|
| 1242 |
|
|
|
|
| 1 |
## Iostreams base classes <a id="iostreams.base">[[iostreams.base]]</a>
|
| 2 |
|
| 3 |
+
### Header `<ios>` synopsis <a id="ios.syn">[[ios.syn]]</a>
|
| 4 |
|
| 5 |
``` cpp
|
| 6 |
+
#include <iosfwd> // see [iosfwd.syn]
|
| 7 |
|
| 8 |
namespace std {
|
| 9 |
+
using streamoff = implementation-defined;
|
| 10 |
+
using streamsize = implementation-defined;
|
| 11 |
template <class stateT> class fpos;
|
| 12 |
|
| 13 |
class ios_base;
|
| 14 |
template <class charT, class traits = char_traits<charT>>
|
| 15 |
class basic_ios;
|
| 16 |
|
| 17 |
+
// [std.ios.manip], manipulators
|
| 18 |
ios_base& boolalpha (ios_base& str);
|
| 19 |
ios_base& noboolalpha(ios_base& str);
|
| 20 |
|
| 21 |
ios_base& showbase (ios_base& str);
|
| 22 |
ios_base& noshowbase (ios_base& str);
|
|
|
|
| 34 |
ios_base& nouppercase(ios_base& str);
|
| 35 |
|
| 36 |
ios_base& unitbuf (ios_base& str);
|
| 37 |
ios_base& nounitbuf (ios_base& str);
|
| 38 |
|
| 39 |
+
// [adjustfield.manip], adjustfield
|
| 40 |
ios_base& internal (ios_base& str);
|
| 41 |
ios_base& left (ios_base& str);
|
| 42 |
ios_base& right (ios_base& str);
|
| 43 |
|
| 44 |
+
// [basefield.manip], basefield
|
| 45 |
ios_base& dec (ios_base& str);
|
| 46 |
ios_base& hex (ios_base& str);
|
| 47 |
ios_base& oct (ios_base& str);
|
| 48 |
|
| 49 |
+
// [floatfield.manip], floatfield
|
| 50 |
ios_base& fixed (ios_base& str);
|
| 51 |
ios_base& scientific (ios_base& str);
|
| 52 |
ios_base& hexfloat (ios_base& str);
|
| 53 |
ios_base& defaultfloat(ios_base& str);
|
| 54 |
|
| 55 |
+
// [error.reporting], error reporting
|
| 56 |
enum class io_errc {
|
| 57 |
stream = 1
|
| 58 |
};
|
| 59 |
|
| 60 |
template <> struct is_error_code_enum<io_errc> : public true_type { };
|
|
|
|
| 65 |
```
|
| 66 |
|
| 67 |
### Types <a id="stream.types">[[stream.types]]</a>
|
| 68 |
|
| 69 |
``` cpp
|
| 70 |
+
using streamoff = implementation-defined;
|
| 71 |
```
|
| 72 |
|
| 73 |
The type `streamoff` is a synonym for one of the signed basic integral
|
| 74 |
types of sufficient size to represent the maximum possible file size for
|
| 75 |
the operating system.[^4]
|
| 76 |
|
| 77 |
``` cpp
|
| 78 |
+
using streamsize = implementation-defined;
|
| 79 |
```
|
| 80 |
|
| 81 |
The type `streamsize` is a synonym for one of the signed basic integral
|
| 82 |
types. It is used to represent the number of characters transferred in
|
| 83 |
an I/O operation, or the size of I/O buffers.[^5]
|
|
|
|
| 86 |
|
| 87 |
``` cpp
|
| 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;
|
| 99 |
static constexpr fmtflags internal = 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 |
|
| 136 |
class Init;
|
| 137 |
|
| 138 |
+
// [fmtflags.state], fmtflags state
|
| 139 |
fmtflags flags() const;
|
| 140 |
fmtflags flags(fmtflags fmtfl);
|
| 141 |
fmtflags setf(fmtflags fmtfl);
|
| 142 |
fmtflags setf(fmtflags fmtfl, fmtflags mask);
|
| 143 |
void unsetf(fmtflags mask);
|
|
|
|
| 145 |
streamsize precision() const;
|
| 146 |
streamsize precision(streamsize prec);
|
| 147 |
streamsize width() const;
|
| 148 |
streamsize width(streamsize wide);
|
| 149 |
|
| 150 |
+
// [ios.base.locales], locales
|
| 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 |
|
|
|
|
| 182 |
|
| 183 |
`ios_base`
|
| 184 |
|
| 185 |
defines several member types:
|
| 186 |
|
| 187 |
+
- a type `failure`, defined as either a class derived from
|
| 188 |
+
`system_error` or a synonym for a class derived from `system_error`;
|
| 189 |
- a class `Init`;
|
| 190 |
- three bitmask types, `fmtflags`, `iostate`, and `openmode`;
|
| 191 |
- an enumerated type, `seekdir`.
|
| 192 |
|
| 193 |
It maintains several kinds of data:
|
|
|
|
| 196 |
- control information that influences how to interpret (format) input
|
| 197 |
sequences and how to generate (format) output sequences;
|
| 198 |
- additional information that is stored by the program for its private
|
| 199 |
use.
|
| 200 |
|
| 201 |
+
[*Note 1*:
|
| 202 |
+
|
| 203 |
For the sake of exposition, the maintained data is presented here as:
|
| 204 |
|
| 205 |
- `static int index`, specifies the next available unique index for the
|
| 206 |
integer or pointer arrays maintained for the private use of the
|
| 207 |
program, initialized to an unspecified value;
|
| 208 |
- `long* iarray`, points to the first element of an arbitrary-length
|
| 209 |
`long` array maintained for the private use of the program;
|
| 210 |
- `void** parray`, points to the first element of an arbitrary-length
|
| 211 |
pointer array maintained for the private use of the program.
|
| 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
|
|
|
|
| 224 |
explicit failure(const char* msg, const error_code& ec = io_errc::stream);
|
| 225 |
};
|
| 226 |
}
|
| 227 |
```
|
| 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 |
|
| 241 |
When throwing `ios_base::failure` exceptions, implementations should
|
| 242 |
provide values of `ec` that identify the specific reason for the
|
| 243 |
+
failure.
|
| 244 |
+
|
| 245 |
+
[*Note 2*: Errors arising from the operating system would typically be
|
| 246 |
reported as `system_category()` errors with an error value of the error
|
| 247 |
number reported by the operating system. Errors arising from within the
|
| 248 |
stream library would typically be reported as
|
| 249 |
`error_code(io_errc::stream,
|
| 250 |
+
iostream_category())`. — *end note*]
|
| 251 |
|
| 252 |
``` cpp
|
| 253 |
explicit failure(const string& msg, const error_code& ec = io_errc::stream);
|
| 254 |
```
|
| 255 |
|
|
|
|
| 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]].
|
|
|
|
| 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 |
|
|
|
|
| 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 |
|
|
|
|
| 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]].
|
|
|
|
| 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.
|
|
|
|
| 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 |
|
| 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 |
|
| 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 |
|
|
|
|
| 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 |
|
|
|
|
| 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
|
| 519 |
allows the standard streams to operate independently of the standard C
|
| 520 |
streams.
|
| 521 |
|
| 522 |
When a standard iostream object `str` is *synchronized* with a standard
|
| 523 |
stdio stream `f`, the effect of inserting a character `c` by
|
|
|
|
| 581 |
necessary to include the element `iarray[idx]`. Each newly allocated
|
| 582 |
element of the array is initialized to zero. The reference returned is
|
| 583 |
invalid after any other operations on the object.[^7] However, the value
|
| 584 |
of the storage referred to is retained, so that until the next call to
|
| 585 |
`copyfmt`, calling `iword` with the same index yields another reference
|
| 586 |
+
to the same value. If the function fails[^8] and `*this` is a base class
|
| 587 |
subobject of a `basic_ios<>` object or subobject, the effect is
|
| 588 |
equivalent to calling `basic_ios<>::setstate(badbit)` on the derived
|
| 589 |
object (which may throw `failure`).
|
| 590 |
|
| 591 |
*Returns:* On success `iarray[idx]`. On failure, a valid `long&`
|
|
|
|
| 602 |
element of the array is initialized to a null pointer. The reference
|
| 603 |
returned is invalid after any other operations on the object. However,
|
| 604 |
the value of the storage referred to is retained, so that until the next
|
| 605 |
call to `copyfmt`, calling `pword` with the same index yields another
|
| 606 |
reference to the same value. If the function fails[^9] and `*this` is a
|
| 607 |
+
base class subobject of a `basic_ios<>` object or subobject, the effect
|
| 608 |
+
is equivalent to calling `basic_ios<>::setstate(badbit)` on the derived
|
| 609 |
object (which may throw `failure`).
|
| 610 |
|
| 611 |
*Returns:* On success `parray[idx]`. On failure a valid `void*&`
|
| 612 |
initialized to 0.
|
| 613 |
|
|
|
|
| 656 |
|
| 657 |
``` cpp
|
| 658 |
namespace std {
|
| 659 |
template <class stateT> class fpos {
|
| 660 |
public:
|
| 661 |
+
// [fpos.members], members
|
| 662 |
stateT state() const;
|
| 663 |
void state(stateT);
|
| 664 |
private;
|
| 665 |
stateT st; // exposition only
|
| 666 |
};
|
|
|
|
| 671 |
|
| 672 |
``` cpp
|
| 673 |
void state(stateT s);
|
| 674 |
```
|
| 675 |
|
| 676 |
+
*Effects:* Assigns `s` to `st`.
|
| 677 |
|
| 678 |
``` cpp
|
| 679 |
stateT state() const;
|
| 680 |
```
|
| 681 |
|
|
|
|
| 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
|
|
|
|
| 712 |
``` cpp
|
| 713 |
namespace std {
|
| 714 |
template <class charT, class traits = char_traits<charT>>
|
| 715 |
class basic_ios : public ios_base {
|
| 716 |
public:
|
| 717 |
+
using char_type = charT;
|
| 718 |
+
using int_type = typename traits::int_type;
|
| 719 |
+
using pos_type = typename traits::pos_type;
|
| 720 |
+
using off_type = typename traits::off_type;
|
| 721 |
+
using traits_type = traits;
|
| 722 |
|
| 723 |
+
// [iostate.flags], flags functions
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 724 |
explicit operator bool() const;
|
| 725 |
bool operator!() const;
|
| 726 |
iostate rdstate() const;
|
| 727 |
void clear(iostate state = goodbit);
|
| 728 |
void setstate(iostate state);
|
|
|
|
| 732 |
bool bad() const;
|
| 733 |
|
| 734 |
iostate exceptions() const;
|
| 735 |
void exceptions(iostate except);
|
| 736 |
|
| 737 |
+
// [basic.ios.cons], constructor/destructor
|
| 738 |
explicit basic_ios(basic_streambuf<charT, traits>* sb);
|
| 739 |
virtual ~basic_ios();
|
| 740 |
|
| 741 |
+
// [basic.ios.members], members
|
| 742 |
basic_ostream<charT, traits>* tie() const;
|
| 743 |
basic_ostream<charT, traits>* tie(basic_ostream<charT, traits>* tiestr);
|
| 744 |
|
| 745 |
basic_streambuf<charT, traits>* rdbuf() const;
|
| 746 |
basic_streambuf<charT, traits>* rdbuf(basic_streambuf<charT, traits>* sb);
|
|
|
|
| 811 |
| `rdstate()` | `goodbit` if `sb` is not a null pointer, otherwise `badbit`. |
|
| 812 |
| `exceptions()` | `goodbit` |
|
| 813 |
| `flags()` | `skipws | dec` |
|
| 814 |
| `width()` | `0` |
|
| 815 |
| `precision()` | `6` |
|
| 816 |
+
| `fill()` | `widen(' ')` |
|
| 817 |
| `getloc()` | a copy of the value returned by `locale()` |
|
| 818 |
| `iarray` | a null pointer |
|
| 819 |
| `parray` | a null pointer |
|
| 820 |
|
| 821 |
|
|
|
|
| 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 |
|
| 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 |
|
|
|
|
| 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);
|
|
|
|
| 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>
|
|
|
|
| 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);
|
|
|
|
| 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 |
|
|
|
|
| 1244 |
*Effects:* Calls
|
| 1245 |
`str.setf(ios_base::fixed | ios_base::scientific, ios_base::floatfield)`.
|
| 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 |
|