This commit is contained in:
2025-10-25 03:02:53 +03:00
commit 043225d523
3416 changed files with 681196 additions and 0 deletions

734
cppdraft/ios/base.md Normal file
View File

@@ -0,0 +1,734 @@
[ios.base]
# 31 Input/output library [[input.output]](./#input.output)
## 31.5 Iostreams base classes [[iostreams.base]](iostreams.base#ios.base)
### 31.5.2 Class ios_base [ios.base]
#### [31.5.2.1](#general) General [[ios.base.general]](ios.base.general)
[🔗](#lib:ios_base)
namespace std {class ios_base {public:class failure; // see below// [[ios.fmtflags]](#ios.fmtflags "31.5.2.2.2Type ios_­base::fmtflags"), fmtflagsusing fmtflags = *T1*; static constexpr fmtflags boolalpha = *unspecified*; static constexpr fmtflags dec = *unspecified*; static constexpr fmtflags fixed = *unspecified*; static constexpr fmtflags hex = *unspecified*; static constexpr fmtflags internal = *unspecified*; static constexpr fmtflags left = *unspecified*; static constexpr fmtflags oct = *unspecified*; static constexpr fmtflags right = *unspecified*; static constexpr fmtflags scientific = *unspecified*; static constexpr fmtflags showbase = *unspecified*; static constexpr fmtflags showpoint = *unspecified*; static constexpr fmtflags showpos = *unspecified*; static constexpr fmtflags skipws = *unspecified*; static constexpr fmtflags unitbuf = *unspecified*; static constexpr fmtflags uppercase = *unspecified*; static constexpr fmtflags adjustfield = *see below*; static constexpr fmtflags basefield = *see below*; static constexpr fmtflags floatfield = *see below*; // [[ios.iostate]](#ios.iostate "31.5.2.2.3Type ios_­base::iostate"), iostateusing iostate = *T2*; static constexpr iostate badbit = *unspecified*; static constexpr iostate eofbit = *unspecified*; static constexpr iostate failbit = *unspecified*; static constexpr iostate goodbit = *see below*; // [[ios.openmode]](#ios.openmode "31.5.2.2.4Type ios_­base::openmode"), openmodeusing openmode = *T3*; static constexpr openmode app = *unspecified*; static constexpr openmode ate = *unspecified*; static constexpr openmode binary = *unspecified*; static constexpr openmode in = *unspecified*; static constexpr openmode noreplace = *unspecified*; static constexpr openmode out = *unspecified*; static constexpr openmode trunc = *unspecified*; // [[ios.seekdir]](#ios.seekdir "31.5.2.2.5Type ios_­base::seekdir"), seekdirusing seekdir = *T4*; static constexpr seekdir beg = *unspecified*; static constexpr seekdir cur = *unspecified*; static constexpr seekdir end = *unspecified*; class Init; // [[fmtflags.state]](#fmtflags.state "31.5.2.3State functions"), fmtflags state fmtflags flags() const;
fmtflags flags(fmtflags fmtfl);
fmtflags setf(fmtflags fmtfl);
fmtflags setf(fmtflags fmtfl, fmtflags mask); void unsetf(fmtflags mask);
streamsize precision() const;
streamsize precision(streamsize prec);
streamsize width() const;
streamsize width(streamsize wide); // [[ios.base.locales]](#locales "31.5.2.4Functions"), locales locale imbue(const locale& loc);
locale getloc() const; // [[ios.base.storage]](#storage "31.5.2.6Storage functions"), storagestatic int xalloc(); long& iword(int idx); void*& pword(int idx); // destructorvirtual ~ios_base(); // [[ios.base.callback]](#callback "31.5.2.7Callbacks"), callbacksenum [event](#lib:ios_base,event "31.5.2.1General[ios.base.general]") { erase_event, imbue_event, copyfmt_event }; using event_callback = void (*)(event, ios_base&, int idx); void register_callback(event_callback fn, int idx);
ios_base(const ios_base&) = delete;
ios_base& operator=(const ios_base&) = delete; static bool sync_with_stdio(bool sync = true); protected: ios_base(); private:static int *index*; // *exposition only*long* *iarray*; // *exposition only*void** *parray*; // *exposition only*};}
[1](#general-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L854)
ios_base defines several member types:
- [(1.1)](#general-1.1)
a type failure, defined as either a class derived fromsystem_error or a synonym for a class derived from system_error;
- [(1.2)](#general-1.2)
a class Init;
- [(1.3)](#general-1.3)
three bitmask types, fmtflags, iostate, and openmode;
- [(1.4)](#general-1.4)
an enumerated type, seekdir[.](#general-1.sentence-1)
[2](#general-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L868)
It maintains several kinds of data:
- [(2.1)](#general-2.1)
state information that reflects the integrity of the stream buffer;
- [(2.2)](#general-2.2)
control information that influences how to interpret (format) input
sequences and how to generate (format) output sequences;
- [(2.3)](#general-2.3)
additional information that is stored by the program for its private use[.](#general-2.sentence-1)
[3](#general-3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L880)
[*Note [1](#general-note-1)*:
For the sake of exposition, the maintained data is presented here as:
- [(3.1)](#general-3.1)
static int *index*,
specifies the next available
unique index for the integer or pointer arrays maintained for the private use
of the program, initialized to an unspecified value;
- [(3.2)](#general-3.2)
long* *iarray*,
points to the first element of an
arbitrary-lengthlong array maintained for the private use of the
program;
- [(3.3)](#general-3.3)
void** *parray*,
points to the first element of an
arbitrary-length pointer array maintained for the private use of the program[.](#general-3.sentence-1)
— *end note*]
#### [31.5.2.2](#ios.types) Types [[ios.types]](ios.types)
#### [31.5.2.2.1](#ios.failure) Class ios_base::failure [[ios.failure]](ios.failure)
[🔗](#lib:ios_base::failure)
namespace std {class ios_base::failure : public system_error {public:explicit failure(const string& msg, const error_code& ec = io_errc::stream); explicit failure(const char* msg, const error_code& ec = io_errc::stream); };}
[1](#ios.failure-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L919)
An implementation is permitted to define ios_base::failure as a synonym for a class with equivalent functionality
to class ios_base::failure shown in this subclause[.](#ios.failure-1.sentence-1)
[*Note [1](#ios.failure-note-1)*:
When ios_base::failure is a synonym for another type,
that type needs to provide a nested type failure to emulate the injected-class-name[.](#ios.failure-1.sentence-2)
— *end note*]
The classfailure defines the base class
for the types of all objects thrown as exceptions,
by functions in the iostreams library,
to report errors detected during stream buffer operations[.](#ios.failure-1.sentence-3)
[2](#ios.failure-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L935)
When throwing ios_base::failure exceptions, implementations should provide
values of ec that identify the specific reason for the failure[.](#ios.failure-2.sentence-1)
[*Note [2](#ios.failure-note-2)*:
Errors arising from the operating system would typically be reported assystem_category() errors with an error value of the error number
reported by the operating system[.](#ios.failure-2.sentence-2)
Errors arising from within the stream library would
typically be reported as error_code(io_errc::stream,
iostream_category())[.](#ios.failure-2.sentence-3)
— *end note*]
[🔗](#lib:ios_base::failure,constructor)
`explicit failure(const string& msg, const error_code& ec = io_errc::stream);
`
[3](#ios.failure-3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L952)
*Effects*: Constructs the base class with msg and ec[.](#ios.failure-3.sentence-1)
[🔗](#lib:ios_base::failure,constructor_)
`explicit failure(const char* msg, const error_code& ec = io_errc::stream);
`
[4](#ios.failure-4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L963)
*Effects*: Constructs the base class with msg and ec[.](#ios.failure-4.sentence-1)
#### [31.5.2.2.2](#ios.fmtflags) Type ios_base::fmtflags [[ios.fmtflags]](ios.fmtflags)
[🔗](#lib:fmtflags,ios_base)
`using fmtflags = T1;
`
[1](#ios.fmtflags-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L976)
The typefmtflags is a bitmask type ([[bitmask.types]](bitmask.types "16.3.3.3.3Bitmask types"))[.](#ios.fmtflags-1.sentence-1)
Setting its elements has the effects indicated in Table [136](#tab:ios.fmtflags "Table 136: fmtflags effects")[.](#ios.fmtflags-1.sentence-2)
Table [136](#tab:ios.fmtflags) — fmtflags effects [[tab:ios.fmtflags]](./tab:ios.fmtflags)
| [🔗](#tab:ios.fmtflags-row-1)<br>**Element** | **Effect(s) if set** |
| --- | --- |
| [🔗](#tab:ios.fmtflags-row-2)<br>boolalpha | insert and extract bool type in alphabetic format |
| [🔗](#tab:ios.fmtflags-row-3)<br>dec | converts integer input or generates integer output in decimal base |
| [🔗](#tab:ios.fmtflags-row-4)<br>fixed | generate floating-point output in fixed-point notation |
| [🔗](#tab:ios.fmtflags-row-5)<br>hex | converts integer input or generates integer output in hexadecimal base |
| [🔗](#tab:ios.fmtflags-row-6)<br>internal | adds fill characters at a designated internal point in certain generated output, or identical to right if no such point is designated |
| [🔗](#tab:ios.fmtflags-row-7)<br>left | adds fill characters on the right (final positions) of certain generated output |
| [🔗](#tab:ios.fmtflags-row-8)<br>oct | converts integer input or generates integer output in octal base |
| [🔗](#tab:ios.fmtflags-row-9)<br>right | adds fill characters on the left (initial positions) of certain generated output |
| [🔗](#tab:ios.fmtflags-row-10)<br>scientific | generates floating-point output in scientific notation |
| [🔗](#tab:ios.fmtflags-row-11)<br>showbase | generates a prefix indicating the numeric base of generated integer output |
| [🔗](#tab:ios.fmtflags-row-12)<br>showpoint | generates a decimal-point character unconditionally in generated floating-point output |
| [🔗](#tab:ios.fmtflags-row-13)<br>showpos | generates a + sign in non-negative generated numeric output |
| [🔗](#tab:ios.fmtflags-row-14)<br>skipws | skips leading whitespace before certain input operations |
| [🔗](#tab:ios.fmtflags-row-15)<br>unitbuf | flushes output after each output operation |
| [🔗](#tab:ios.fmtflags-row-16)<br>uppercase | replaces certain lowercase letters with their uppercase equivalents in generated output |
[2](#ios.fmtflags-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L1016)
Typefmtflags also defines the constants indicated in Table [137](#tab:ios.fmtflags.const "Table 137: fmtflags constants")[.](#ios.fmtflags-2.sentence-1)
Table [137](#tab:ios.fmtflags.const) — fmtflags constants [[tab:ios.fmtflags.const]](./tab:ios.fmtflags.const)
| [🔗](#tab:ios.fmtflags.const-row-1)<br>**Constant** | **Allowable values** |
| --- | --- |
| [🔗](#tab:ios.fmtflags.const-row-2)<br>adjustfield | left | right | internal |
| [🔗](#tab:ios.fmtflags.const-row-3)<br>basefield | dec | oct | hex |
| [🔗](#tab:ios.fmtflags.const-row-4)<br>floatfield | scientific | fixed |
#### [31.5.2.2.3](#ios.iostate) Type ios_base::iostate [[ios.iostate]](ios.iostate)
[🔗](#lib:iostate,ios_base)
`using iostate = T2;
`
[1](#ios.iostate-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L1039)
The typeiostate is a bitmask type ([[bitmask.types]](bitmask.types "16.3.3.3.3Bitmask types"))
that contains the elements indicated in Table [138](#tab:ios.iostate "Table 138: iostate effects")[.](#ios.iostate-1.sentence-1)
Table [138](#tab:ios.iostate) — iostate effects [[tab:ios.iostate]](./tab:ios.iostate)
| [🔗](#tab:ios.iostate-row-1)<br>**Element** | **Effect(s) if set** |
| --- | --- |
| [🔗](#tab:ios.iostate-row-2)<br>badbit | indicates a loss of integrity in an input or output sequence (such as an irrecoverable read error from a file); |
| [🔗](#tab:ios.iostate-row-3)<br>eofbit | indicates that an input operation reached the end of an input sequence; |
| [🔗](#tab:ios.iostate-row-4)<br>failbit | indicates that an input operation failed to read the expected characters, or that an output operation failed to generate the desired characters[.](#tab:ios.iostate-row-4-column-2-sentence-1) |
[2](#ios.iostate-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L1056)
Typeiostate also defines the constant:
- [(2.1)](#ios.iostate-2.1)
goodbit,
the value zero[.](#ios.iostate-2.sentence-1)
#### [31.5.2.2.4](#ios.openmode) Type ios_base::openmode [[ios.openmode]](ios.openmode)
[🔗](#lib:openmode,ios_base)
`using openmode = T3;
`
[1](#ios.openmode-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L1075)
The typeopenmode is a bitmask type ([[bitmask.types]](bitmask.types "16.3.3.3.3Bitmask types"))[.](#ios.openmode-1.sentence-1)
It contains the elements indicated in Table [139](#tab:ios.openmode "Table 139: openmode effects")[.](#ios.openmode-1.sentence-2)
Table [139](#tab:ios.openmode) — openmode effects [[tab:ios.openmode]](./tab:ios.openmode)
| [🔗](#tab:ios.openmode-row-1)<br>**Element** | **Effect(s) if set** |
| --- | --- |
| [🔗](#tab:ios.openmode-row-2)<br>app | seek to end before each write |
| [🔗](#tab:ios.openmode-row-3)<br>ate | open and seek to end immediately after opening |
| [🔗](#tab:ios.openmode-row-4)<br>binary | perform input and output in binary mode (as opposed to text mode) |
| [🔗](#tab:ios.openmode-row-5)<br>in | open for input |
| [🔗](#tab:ios.openmode-row-6)<br>noreplace | open in exclusive mode |
| [🔗](#tab:ios.openmode-row-7)<br>out | open for output |
| [🔗](#tab:ios.openmode-row-8)<br>trunc | truncate an existing stream when opening |
#### [31.5.2.2.5](#ios.seekdir) Type ios_base::seekdir [[ios.seekdir]](ios.seekdir)
[🔗](#lib:seekdir,ios_base)
`using seekdir = T4;
`
[1](#ios.seekdir-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L1107)
The typeseekdir is an enumerated type ([[enumerated.types]](enumerated.types "16.3.3.3.2Enumerated types"))
that contains the elements indicated in Table [140](#tab:ios.seekdir "Table 140: seekdir effects")[.](#ios.seekdir-1.sentence-1)
Table [140](#tab:ios.seekdir) — seekdir effects [[tab:ios.seekdir]](./tab:ios.seekdir)
| [🔗](#tab:ios.seekdir-row-1)<br>**Element** | **Meaning** |
| --- | --- |
| [🔗](#tab:ios.seekdir-row-2)<br>beg | request a seek (for subsequent input or output) relative to the beginning of the stream |
| [🔗](#tab:ios.seekdir-row-3)<br>cur | request a seek relative to the current position within the sequence |
| [🔗](#tab:ios.seekdir-row-4)<br>end | request a seek relative to the current end of the sequence |
#### [31.5.2.2.6](#ios.init) Class ios_base::Init [[ios.init]](ios.init)
[🔗](#lib:ios_base::Init)
namespace std {class ios_base::Init {public: Init();
Init(const Init&) = default; ~Init();
Init& operator=(const Init&) = default; };}
[1](#ios.init-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L1139)
The class Init describes an object whose construction
ensures the construction of the eight objects declared in[<iostream>](iostream.syn#header:%3ciostream%3e "31.4.1Header <iostream> synopsis[iostream.syn]") ([[iostream.objects]](iostream.objects "31.4Standard iostream objects")) that associate file
stream buffers with the standard C streams
provided for by the functions declared in[<cstdio>](cstdio.syn#header:%3ccstdio%3e "31.13.1Header <cstdio> synopsis[cstdio.syn]")[.](#ios.init-1.sentence-1)
[🔗](#lib:ios_base::Init,constructor)
`Init();
`
[2](#ios.init-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L1154)
*Effects*: Constructs and initializes the objects cin, cout, cerr,clog, wcin, wcout, wcerr, and wclog if
they have not already been constructed and initialized[.](#ios.init-2.sentence-1)
[🔗](#lib:ios_base::Init,destructor)
`~Init();
`
[3](#ios.init-3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L1167)
*Effects*: If there are no other instances of the class still in existence,
callscout.flush(),cerr.flush(),clog.flush(),wcout.flush(),wcerr.flush(),wclog.flush()[.](#ios.init-3.sentence-1)
#### [31.5.2.3](#fmtflags.state) State functions [[fmtflags.state]](fmtflags.state)
[🔗](#lib:flags,ios_base)
`fmtflags flags() const;
`
[1](#fmtflags.state-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L1188)
*Returns*: The format control information for both input and output[.](#fmtflags.state-1.sentence-1)
[🔗](#lib:flags,ios_base_)
`fmtflags flags(fmtflags fmtfl);
`
[2](#fmtflags.state-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L1199)
*Postconditions*: fmtfl == flags()[.](#fmtflags.state-2.sentence-1)
[3](#fmtflags.state-3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L1203)
*Returns*: The previous value offlags()[.](#fmtflags.state-3.sentence-1)
[🔗](#lib:setf,ios_base)
`fmtflags setf(fmtflags fmtfl);
`
[4](#fmtflags.state-4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L1215)
*Effects*: Sets fmtfl inflags()[.](#fmtflags.state-4.sentence-1)
[5](#fmtflags.state-5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L1220)
*Returns*: The previous value offlags()[.](#fmtflags.state-5.sentence-1)
[🔗](#lib:setf,ios_base_)
`fmtflags setf(fmtflags fmtfl, fmtflags mask);
`
[6](#fmtflags.state-6)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L1232)
*Effects*: Clears mask inflags(),
setsfmtfl & mask inflags()[.](#fmtflags.state-6.sentence-1)
[7](#fmtflags.state-7)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L1241)
*Returns*: The previous value offlags()[.](#fmtflags.state-7.sentence-1)
[🔗](#lib:unsetf,ios_base)
`void unsetf(fmtflags mask);
`
[8](#fmtflags.state-8)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L1253)
*Effects*: Clears mask inflags()[.](#fmtflags.state-8.sentence-1)
[🔗](#lib:precision,ios_base)
`streamsize precision() const;
`
[9](#fmtflags.state-9)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L1265)
*Returns*: The precision
to generate on certain output conversions[.](#fmtflags.state-9.sentence-1)
[🔗](#lib:precision,ios_base_)
`streamsize precision(streamsize prec);
`
[10](#fmtflags.state-10)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L1277)
*Postconditions*: prec == precision()[.](#fmtflags.state-10.sentence-1)
[11](#fmtflags.state-11)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L1281)
*Returns*: The previous value ofprecision()[.](#fmtflags.state-11.sentence-1)
[🔗](#lib:width,ios_base)
`streamsize width() const;
`
[12](#fmtflags.state-12)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L1293)
*Returns*: The minimum field width (number of characters) to generate on certain output
conversions[.](#fmtflags.state-12.sentence-1)
[🔗](#lib:width,ios_base_)
`streamsize width(streamsize wide);
`
[13](#fmtflags.state-13)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L1305)
*Postconditions*: wide == width()[.](#fmtflags.state-13.sentence-1)
[14](#fmtflags.state-14)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L1309)
*Returns*: The previous value ofwidth()[.](#fmtflags.state-14.sentence-1)
#### [31.5.2.4](#locales) Functions [[ios.base.locales]](ios.base.locales)
[🔗](#lib:imbue,ios_base)
`locale imbue(const locale& loc);
`
[1](#locales-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L1323)
*Effects*: Calls each registered callback pair(fn, idx) ([[ios.base.callback]](#callback "31.5.2.7Callbacks"))
as(*fn)(imbue_event, *this, idx) at such a time that a call toios_base::getloc() from withinfn returns the new locale valueloc[.](#locales-1.sentence-1)
[2](#locales-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L1336)
*Postconditions*: loc == getloc()[.](#locales-2.sentence-1)
[3](#locales-3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L1340)
*Returns*: The previous value ofgetloc()[.](#locales-3.sentence-1)
[🔗](#lib:getloc,ios_base)
`locale getloc() const;
`
[4](#locales-4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L1352)
*Returns*: If no locale has been imbued, a copy of the global C++ locale,locale(),
in effect at the time of construction[.](#locales-4.sentence-1)
Otherwise, returns the imbued locale, to be used to
perform locale-dependent input and output operations[.](#locales-4.sentence-2)
#### [31.5.2.5](#ios.members.static) Static members [[ios.members.static]](ios.members.static)
[🔗](#lib:sync_with_stdio,ios_base)
`static bool sync_with_stdio(bool sync = true);
`
[1](#ios.members.static-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L1369)
*Effects*: If any input or output operation has occurred using the standard streams prior to the
call, the effect isimplementation-defined[.](#ios.members.static-1.sentence-1)
Otherwise, called with a false argument, it allows the standard streams to
operate independently of the standard C streams[.](#ios.members.static-1.sentence-2)
[2](#ios.members.static-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L1378)
*Returns*: true if the previous state of the [standard iostream objects](iostream.objects "31.4Standard iostream objects[iostream.objects]") was synchronized and otherwise returnsfalse[.](#ios.members.static-2.sentence-1)
The first time it is called,
the function returnstrue[.](#ios.members.static-2.sentence-2)
[3](#ios.members.static-3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L1388)
*Remarks*: When a standard iostream object str is*synchronized* with a standard stdio stream f, the effect of inserting a character c byfputc(f, c); is the same as the effect ofstr.rdbuf()->sputc(c); for any sequences of characters; the effect of extracting a character c byc = fgetc(f); is the same as the effect ofc = str.rdbuf()->sbumpc(); for any sequences of characters; and the effect of pushing back a character c byungetc(c, f); is the same as the effect ofstr.rdbuf()->sputbackc(c); for any sequence of characters[.](#ios.members.static-3.sentence-1)[259](#footnote-259 "This implies that operations on a standard iostream object can be mixed arbitrarily with operations on the corresponding stdio stream. In practical terms, synchronization usually means that a standard iostream object and a standard stdio object share a buffer.")
[259)](#footnote-259)[259)](#footnoteref-259)
This implies that operations on a standard iostream object can be mixed arbitrarily
with operations on the corresponding stdio stream[.](#footnote-259.sentence-1)
In practical terms, synchronization
usually means that a standard iostream object and a standard stdio object share a
buffer[.](#footnote-259.sentence-2)
#### [31.5.2.6](#storage) Storage functions [[ios.base.storage]](ios.base.storage)
[🔗](#lib:xalloc,ios_base)
`static int xalloc();
`
[1](#storage-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L1433)
*Returns*: *index*++[.](#storage-1.sentence-1)
[2](#storage-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L1438)
*Remarks*: Concurrent access to this function by multiple threads does not result in a[data race](intro.multithread#def:data_race "6.10.2Multi-threaded executions and data races[intro.multithread]")[.](#storage-2.sentence-1)
[🔗](#lib:iword,ios_base)
`long& iword(int idx);
`
[3](#storage-3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L1450)
*Preconditions*: idx is a value obtained by a call to xalloc[.](#storage-3.sentence-1)
[4](#storage-4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L1454)
*Effects*: If *iarray* is a null pointer, allocates an array oflong of unspecified size and stores a pointer to its first element in*iarray*[.](#storage-4.sentence-1)
The function then extends the array pointed at by*iarray* as necessary to include the element*iarray*[idx][.](#storage-4.sentence-2)
Each newly allocated element of the array is initialized to zero[.](#storage-4.sentence-3)
The reference returned is invalid after any other operation on the
object[.](#storage-4.sentence-4)[260](#footnote-260 "An implementation is free to implement both the integer array pointed at by iarray and the pointer array pointed at by parray as sparse data structures, possibly with a one-element cache for each.")
However, the value of the storage referred to is retained, so
that until the next call tocopyfmt,
callingiword with the same index yields another reference to the same value[.](#storage-4.sentence-5)
If the function fails[261](#footnote-261 "For example, because it cannot allocate space.") and*this is a base class subobject of abasic_ios<> object or subobject, the effect is equivalent to callingbasic_ios<>::setstate(badbit) on the derived object (which may throwfailure)[.](#storage-4.sentence-6)
[5](#storage-5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L1491)
*Returns*: On success*iarray*[idx][.](#storage-5.sentence-1)
On failure, a validlong& initialized to 0[.](#storage-5.sentence-2)
[🔗](#lib:pword,ios_base)
`void*& pword(int idx);
`
[6](#storage-6)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L1506)
*Preconditions*: idx is a value obtained by a call to xalloc[.](#storage-6.sentence-1)
[7](#storage-7)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L1510)
*Effects*: If *parray* is a null pointer, allocates an array of
pointers to void of unspecified size and stores a pointer to
its
first element in *parray*[.](#storage-7.sentence-1)
The function then extends the array
pointed at by *parray* as necessary to include the element*parray*[idx][.](#storage-7.sentence-2)
Each newly allocated element of the array is initialized to a null
pointer[.](#storage-7.sentence-3)
The reference returned is invalid after any other operation on the
object[.](#storage-7.sentence-4)
However, the value of the storage referred to is retained, so
that until the next call tocopyfmt,
callingpword with the same index yields another reference to the same value[.](#storage-7.sentence-5)
If the function fails[262](#footnote-262 "For example, because it cannot allocate space.") and*this is a base class subobject of abasic_ios<> object or subobject, the effect is equivalent to callingbasic_ios<>::setstate(badbit) on the derived object (which may throwfailure)[.](#storage-7.sentence-6)
[8](#storage-8)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L1542)
*Returns*: On successparray[idx][.](#storage-8.sentence-1)
On failure a validvoid*& initialized to 0[.](#storage-8.sentence-2)
[9](#storage-9)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L1550)
*Remarks*: After a subsequent call topword(int) for the same object, the earlier return value may no longer be valid[.](#storage-9.sentence-1)
[260)](#footnote-260)[260)](#footnoteref-260)
An implementation is free to implement both the integer
array pointed at by *iarray* and the pointer array pointed at by*parray* as sparse data structures, possibly with a one-element
cache for each[.](#footnote-260.sentence-1)
[261)](#footnote-261)[261)](#footnoteref-261)
For example, because it cannot allocate space[.](#footnote-261.sentence-1)
[262)](#footnote-262)[262)](#footnoteref-262)
For example, because it cannot allocate space[.](#footnote-262.sentence-1)
#### [31.5.2.7](#callback) Callbacks [[ios.base.callback]](ios.base.callback)
[🔗](#lib:register_callback,ios_base)
`void register_callback(event_callback fn, int idx);
`
[1](#callback-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L1565)
*Preconditions*: The functionfn does not throw exceptions[.](#callback-1.sentence-1)
[2](#callback-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L1571)
*Effects*: Registers the pair(fn, idx) such that during calls toimbue() ([[ios.base.locales]](#locales "31.5.2.4Functions")),copyfmt(),
or~ios_base() ([[ios.base.cons]](#cons "31.5.2.8Constructors and destructor")),
the functionfn is called with argumentidx[.](#callback-2.sentence-1)
Functions registered are called when an event occurs, in opposite order of
registration[.](#callback-2.sentence-2)
Functions registered while a callback function is active are not called until the next event[.](#callback-2.sentence-3)
[3](#callback-3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L1588)
*Remarks*: Identical pairs are not merged[.](#callback-3.sentence-1)
A function registered twice will be called twice[.](#callback-3.sentence-2)
#### [31.5.2.8](#cons) Constructors and destructor [[ios.base.cons]](ios.base.cons)
[🔗](#lib:ios_base,constructor)
`ios_base();
`
[1](#cons-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L1602)
*Effects*: Eachios_base member has an indeterminate value after construction[.](#cons-1.sentence-1)
The object's members shall be initialized by callingbasic_ios::init before the object's first use or before it is destroyed, whichever comes first; otherwise
the behavior is undefined[.](#cons-1.sentence-2)
[🔗](#lib:ios_base,destructor)
`~ios_base();
`
[2](#cons-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L1619)
*Effects*: Calls each registered callback pair(fn, idx) ([[ios.base.callback]](#callback "31.5.2.7Callbacks")) as(*fn)(erase_event, *this, idx) at such time that anyios_base member function called from withinfn has well-defined results[.](#cons-2.sentence-1)
Then, any memory obtained is deallocated[.](#cons-2.sentence-2)

View File

@@ -0,0 +1,41 @@
[ios.base.callback]
# 31 Input/output library [[input.output]](./#input.output)
## 31.5 Iostreams base classes [[iostreams.base]](iostreams.base#ios.base.callback)
### 31.5.2 Class ios_base [[ios.base]](ios.base#callback)
#### 31.5.2.7 Callbacks [ios.base.callback]
[🔗](#lib:register_callback,ios_base)
`void register_callback(event_callback fn, int idx);
`
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L1565)
*Preconditions*: The functionfn does not throw exceptions[.](#1.sentence-1)
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L1571)
*Effects*: Registers the pair(fn, idx) such that during calls toimbue() ([[ios.base.locales]](ios.base.locales "31.5.2.4Functions")),copyfmt(),
or~ios_base() ([[ios.base.cons]](ios.base.cons "31.5.2.8Constructors and destructor")),
the functionfn is called with argumentidx[.](#2.sentence-1)
Functions registered are called when an event occurs, in opposite order of
registration[.](#2.sentence-2)
Functions registered while a callback function is active are not called until the next event[.](#2.sentence-3)
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L1588)
*Remarks*: Identical pairs are not merged[.](#3.sentence-1)
A function registered twice will be called twice[.](#3.sentence-2)

36
cppdraft/ios/base/cons.md Normal file
View File

@@ -0,0 +1,36 @@
[ios.base.cons]
# 31 Input/output library [[input.output]](./#input.output)
## 31.5 Iostreams base classes [[iostreams.base]](iostreams.base#ios.base.cons)
### 31.5.2 Class ios_base [[ios.base]](ios.base#cons)
#### 31.5.2.8 Constructors and destructor [ios.base.cons]
[🔗](#lib:ios_base,constructor)
`ios_base();
`
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L1602)
*Effects*: Eachios_base member has an indeterminate value after construction[.](#1.sentence-1)
The object's members shall be initialized by callingbasic_ios::init before the object's first use or before it is destroyed, whichever comes first; otherwise
the behavior is undefined[.](#1.sentence-2)
[🔗](#lib:ios_base,destructor)
`~ios_base();
`
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L1619)
*Effects*: Calls each registered callback pair(fn, idx) ([[ios.base.callback]](ios.base.callback "31.5.2.7Callbacks")) as(*fn)(erase_event, *this, idx) at such time that anyios_base member function called from withinfn has well-defined results[.](#2.sentence-1)
Then, any memory obtained is deallocated[.](#2.sentence-2)

View File

@@ -0,0 +1,96 @@
[ios.base.general]
# 31 Input/output library [[input.output]](./#input.output)
## 31.5 Iostreams base classes [[iostreams.base]](iostreams.base#ios.base.general)
### 31.5.2 Class ios_base [[ios.base]](ios.base#general)
#### 31.5.2.1 General [ios.base.general]
[🔗](#lib:ios_base)
namespace std {class ios_base {public:class failure; // see below// [[ios.fmtflags]](ios.fmtflags "31.5.2.2.2Type ios_­base::fmtflags"), fmtflagsusing fmtflags = *T1*; static constexpr fmtflags boolalpha = *unspecified*; static constexpr fmtflags dec = *unspecified*; static constexpr fmtflags fixed = *unspecified*; static constexpr fmtflags hex = *unspecified*; static constexpr fmtflags internal = *unspecified*; static constexpr fmtflags left = *unspecified*; static constexpr fmtflags oct = *unspecified*; static constexpr fmtflags right = *unspecified*; static constexpr fmtflags scientific = *unspecified*; static constexpr fmtflags showbase = *unspecified*; static constexpr fmtflags showpoint = *unspecified*; static constexpr fmtflags showpos = *unspecified*; static constexpr fmtflags skipws = *unspecified*; static constexpr fmtflags unitbuf = *unspecified*; static constexpr fmtflags uppercase = *unspecified*; static constexpr fmtflags adjustfield = *see below*; static constexpr fmtflags basefield = *see below*; static constexpr fmtflags floatfield = *see below*; // [[ios.iostate]](ios.iostate "31.5.2.2.3Type ios_­base::iostate"), iostateusing iostate = *T2*; static constexpr iostate badbit = *unspecified*; static constexpr iostate eofbit = *unspecified*; static constexpr iostate failbit = *unspecified*; static constexpr iostate goodbit = *see below*; // [[ios.openmode]](ios.openmode "31.5.2.2.4Type ios_­base::openmode"), openmodeusing openmode = *T3*; static constexpr openmode app = *unspecified*; static constexpr openmode ate = *unspecified*; static constexpr openmode binary = *unspecified*; static constexpr openmode in = *unspecified*; static constexpr openmode noreplace = *unspecified*; static constexpr openmode out = *unspecified*; static constexpr openmode trunc = *unspecified*; // [[ios.seekdir]](ios.seekdir "31.5.2.2.5Type ios_­base::seekdir"), seekdirusing seekdir = *T4*; static constexpr seekdir beg = *unspecified*; static constexpr seekdir cur = *unspecified*; static constexpr seekdir end = *unspecified*; class Init; // [[fmtflags.state]](fmtflags.state "31.5.2.3State functions"), fmtflags state fmtflags flags() const;
fmtflags flags(fmtflags fmtfl);
fmtflags setf(fmtflags fmtfl);
fmtflags setf(fmtflags fmtfl, fmtflags mask); void unsetf(fmtflags mask);
streamsize precision() const;
streamsize precision(streamsize prec);
streamsize width() const;
streamsize width(streamsize wide); // [[ios.base.locales]](ios.base.locales "31.5.2.4Functions"), locales locale imbue(const locale& loc);
locale getloc() const; // [[ios.base.storage]](ios.base.storage "31.5.2.6Storage functions"), storagestatic int xalloc(); long& iword(int idx); void*& pword(int idx); // destructorvirtual ~ios_base(); // [[ios.base.callback]](ios.base.callback "31.5.2.7Callbacks"), callbacksenum [event](#lib:ios_base,event "31.5.2.1General[ios.base.general]") { erase_event, imbue_event, copyfmt_event }; using event_callback = void (*)(event, ios_base&, int idx); void register_callback(event_callback fn, int idx);
ios_base(const ios_base&) = delete;
ios_base& operator=(const ios_base&) = delete; static bool sync_with_stdio(bool sync = true); protected: ios_base(); private:static int *index*; // *exposition only*long* *iarray*; // *exposition only*void** *parray*; // *exposition only*};}
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L854)
ios_base defines several member types:
- [(1.1)](#1.1)
a type failure, defined as either a class derived fromsystem_error or a synonym for a class derived from system_error;
- [(1.2)](#1.2)
a class Init;
- [(1.3)](#1.3)
three bitmask types, fmtflags, iostate, and openmode;
- [(1.4)](#1.4)
an enumerated type, seekdir[.](#1.sentence-1)
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L868)
It maintains several kinds of data:
- [(2.1)](#2.1)
state information that reflects the integrity of the stream buffer;
- [(2.2)](#2.2)
control information that influences how to interpret (format) input
sequences and how to generate (format) output sequences;
- [(2.3)](#2.3)
additional information that is stored by the program for its private use[.](#2.sentence-1)
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L880)
[*Note [1](#note-1)*:
For the sake of exposition, the maintained data is presented here as:
- [(3.1)](#3.1)
static int *index*,
specifies the next available
unique index for the integer or pointer arrays maintained for the private use
of the program, initialized to an unspecified value;
- [(3.2)](#3.2)
long* *iarray*,
points to the first element of an
arbitrary-lengthlong array maintained for the private use of the
program;
- [(3.3)](#3.3)
void** *parray*,
points to the first element of an
arbitrary-length pointer array maintained for the private use of the program[.](#3.sentence-1)
— *end note*]

View File

@@ -0,0 +1,48 @@
[ios.base.locales]
# 31 Input/output library [[input.output]](./#input.output)
## 31.5 Iostreams base classes [[iostreams.base]](iostreams.base#ios.base.locales)
### 31.5.2 Class ios_base [[ios.base]](ios.base#locales)
#### 31.5.2.4 Functions [ios.base.locales]
[🔗](#lib:imbue,ios_base)
`locale imbue(const locale& loc);
`
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L1323)
*Effects*: Calls each registered callback pair(fn, idx) ([[ios.base.callback]](ios.base.callback "31.5.2.7Callbacks"))
as(*fn)(imbue_event, *this, idx) at such a time that a call toios_base::getloc() from withinfn returns the new locale valueloc[.](#1.sentence-1)
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L1336)
*Postconditions*: loc == getloc()[.](#2.sentence-1)
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L1340)
*Returns*: The previous value ofgetloc()[.](#3.sentence-1)
[🔗](#lib:getloc,ios_base)
`locale getloc() const;
`
[4](#4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L1352)
*Returns*: If no locale has been imbued, a copy of the global C++ locale,locale(),
in effect at the time of construction[.](#4.sentence-1)
Otherwise, returns the imbued locale, to be used to
perform locale-dependent input and output operations[.](#4.sentence-2)

View File

@@ -0,0 +1,127 @@
[ios.base.storage]
# 31 Input/output library [[input.output]](./#input.output)
## 31.5 Iostreams base classes [[iostreams.base]](iostreams.base#ios.base.storage)
### 31.5.2 Class ios_base [[ios.base]](ios.base#storage)
#### 31.5.2.6 Storage functions [ios.base.storage]
[🔗](#lib:xalloc,ios_base)
`static int xalloc();
`
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L1433)
*Returns*: *index*++[.](#1.sentence-1)
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L1438)
*Remarks*: Concurrent access to this function by multiple threads does not result in a[data race](intro.multithread#def:data_race "6.10.2Multi-threaded executions and data races[intro.multithread]")[.](#2.sentence-1)
[🔗](#lib:iword,ios_base)
`long& iword(int idx);
`
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L1450)
*Preconditions*: idx is a value obtained by a call to xalloc[.](#3.sentence-1)
[4](#4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L1454)
*Effects*: If *iarray* is a null pointer, allocates an array oflong of unspecified size and stores a pointer to its first element in*iarray*[.](#4.sentence-1)
The function then extends the array pointed at by*iarray* as necessary to include the element*iarray*[idx][.](#4.sentence-2)
Each newly allocated element of the array is initialized to zero[.](#4.sentence-3)
The reference returned is invalid after any other operation on the
object[.](#4.sentence-4)[260](#footnote-260 "An implementation is free to implement both the integer array pointed at by iarray and the pointer array pointed at by parray as sparse data structures, possibly with a one-element cache for each.")
However, the value of the storage referred to is retained, so
that until the next call tocopyfmt,
callingiword with the same index yields another reference to the same value[.](#4.sentence-5)
If the function fails[261](#footnote-261 "For example, because it cannot allocate space.") and*this is a base class subobject of abasic_ios<> object or subobject, the effect is equivalent to callingbasic_ios<>::setstate(badbit) on the derived object (which may throwfailure)[.](#4.sentence-6)
[5](#5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L1491)
*Returns*: On success*iarray*[idx][.](#5.sentence-1)
On failure, a validlong& initialized to 0[.](#5.sentence-2)
[🔗](#lib:pword,ios_base)
`void*& pword(int idx);
`
[6](#6)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L1506)
*Preconditions*: idx is a value obtained by a call to xalloc[.](#6.sentence-1)
[7](#7)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L1510)
*Effects*: If *parray* is a null pointer, allocates an array of
pointers to void of unspecified size and stores a pointer to
its
first element in *parray*[.](#7.sentence-1)
The function then extends the array
pointed at by *parray* as necessary to include the element*parray*[idx][.](#7.sentence-2)
Each newly allocated element of the array is initialized to a null
pointer[.](#7.sentence-3)
The reference returned is invalid after any other operation on the
object[.](#7.sentence-4)
However, the value of the storage referred to is retained, so
that until the next call tocopyfmt,
callingpword with the same index yields another reference to the same value[.](#7.sentence-5)
If the function fails[262](#footnote-262 "For example, because it cannot allocate space.") and*this is a base class subobject of abasic_ios<> object or subobject, the effect is equivalent to callingbasic_ios<>::setstate(badbit) on the derived object (which may throwfailure)[.](#7.sentence-6)
[8](#8)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L1542)
*Returns*: On successparray[idx][.](#8.sentence-1)
On failure a validvoid*& initialized to 0[.](#8.sentence-2)
[9](#9)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L1550)
*Remarks*: After a subsequent call topword(int) for the same object, the earlier return value may no longer be valid[.](#9.sentence-1)
[260)](#footnote-260)[260)](#footnoteref-260)
An implementation is free to implement both the integer
array pointed at by *iarray* and the pointer array pointed at by*parray* as sparse data structures, possibly with a one-element
cache for each[.](#footnote-260.sentence-1)
[261)](#footnote-261)[261)](#footnoteref-261)
For example, because it cannot allocate space[.](#footnote-261.sentence-1)
[262)](#footnote-262)[262)](#footnoteref-262)
For example, because it cannot allocate space[.](#footnote-262.sentence-1)

74
cppdraft/ios/failure.md Normal file
View File

@@ -0,0 +1,74 @@
[ios.failure]
# 31 Input/output library [[input.output]](./#input.output)
## 31.5 Iostreams base classes [[iostreams.base]](iostreams.base#ios.failure)
### 31.5.2 Class ios_base [[ios.base]](ios.base#ios.failure)
#### 31.5.2.2 Types [[ios.types]](ios.types#ios.failure)
#### 31.5.2.2.1 Class ios_base::failure [ios.failure]
[🔗](#lib:ios_base::failure)
namespace std {class ios_base::failure : public system_error {public:explicit failure(const string& msg, const error_code& ec = io_errc::stream); explicit failure(const char* msg, const error_code& ec = io_errc::stream); };}
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L919)
An implementation is permitted to define ios_base::failure as a synonym for a class with equivalent functionality
to class ios_base::failure shown in this subclause[.](#1.sentence-1)
[*Note [1](#note-1)*:
When ios_base::failure is a synonym for another type,
that type needs to provide a nested type failure to emulate the injected-class-name[.](#1.sentence-2)
— *end note*]
The classfailure defines the base class
for the types of all objects thrown as exceptions,
by functions in the iostreams library,
to report errors detected during stream buffer operations[.](#1.sentence-3)
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L935)
When throwing ios_base::failure exceptions, implementations should provide
values of ec that identify the specific reason for the failure[.](#2.sentence-1)
[*Note [2](#note-2)*:
Errors arising from the operating system would typically be reported assystem_category() errors with an error value of the error number
reported by the operating system[.](#2.sentence-2)
Errors arising from within the stream library would
typically be reported as error_code(io_errc::stream,
iostream_category())[.](#2.sentence-3)
— *end note*]
[🔗](#lib:ios_base::failure,constructor)
`explicit failure(const string& msg, const error_code& ec = io_errc::stream);
`
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L952)
*Effects*: Constructs the base class with msg and ec[.](#3.sentence-1)
[🔗](#lib:ios_base::failure,constructor_)
`explicit failure(const char* msg, const error_code& ec = io_errc::stream);
`
[4](#4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L963)
*Effects*: Constructs the base class with msg and ec[.](#4.sentence-1)

58
cppdraft/ios/fmtflags.md Normal file
View File

@@ -0,0 +1,58 @@
[ios.fmtflags]
# 31 Input/output library [[input.output]](./#input.output)
## 31.5 Iostreams base classes [[iostreams.base]](iostreams.base#ios.fmtflags)
### 31.5.2 Class ios_base [[ios.base]](ios.base#ios.fmtflags)
#### 31.5.2.2 Types [[ios.types]](ios.types#ios.fmtflags)
#### 31.5.2.2.2 Type ios_base::fmtflags [ios.fmtflags]
[🔗](#lib:fmtflags,ios_base)
`using fmtflags = T1;
`
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L976)
The typefmtflags is a bitmask type ([[bitmask.types]](bitmask.types "16.3.3.3.3Bitmask types"))[.](#1.sentence-1)
Setting its elements has the effects indicated in Table [136](#tab:ios.fmtflags "Table 136: fmtflags effects")[.](#1.sentence-2)
Table [136](#tab:ios.fmtflags) — fmtflags effects [[tab:ios.fmtflags]](./tab:ios.fmtflags)
| [🔗](#tab:ios.fmtflags-row-1)<br>**Element** | **Effect(s) if set** |
| --- | --- |
| [🔗](#tab:ios.fmtflags-row-2)<br>boolalpha | insert and extract bool type in alphabetic format |
| [🔗](#tab:ios.fmtflags-row-3)<br>dec | converts integer input or generates integer output in decimal base |
| [🔗](#tab:ios.fmtflags-row-4)<br>fixed | generate floating-point output in fixed-point notation |
| [🔗](#tab:ios.fmtflags-row-5)<br>hex | converts integer input or generates integer output in hexadecimal base |
| [🔗](#tab:ios.fmtflags-row-6)<br>internal | adds fill characters at a designated internal point in certain generated output, or identical to right if no such point is designated |
| [🔗](#tab:ios.fmtflags-row-7)<br>left | adds fill characters on the right (final positions) of certain generated output |
| [🔗](#tab:ios.fmtflags-row-8)<br>oct | converts integer input or generates integer output in octal base |
| [🔗](#tab:ios.fmtflags-row-9)<br>right | adds fill characters on the left (initial positions) of certain generated output |
| [🔗](#tab:ios.fmtflags-row-10)<br>scientific | generates floating-point output in scientific notation |
| [🔗](#tab:ios.fmtflags-row-11)<br>showbase | generates a prefix indicating the numeric base of generated integer output |
| [🔗](#tab:ios.fmtflags-row-12)<br>showpoint | generates a decimal-point character unconditionally in generated floating-point output |
| [🔗](#tab:ios.fmtflags-row-13)<br>showpos | generates a + sign in non-negative generated numeric output |
| [🔗](#tab:ios.fmtflags-row-14)<br>skipws | skips leading whitespace before certain input operations |
| [🔗](#tab:ios.fmtflags-row-15)<br>unitbuf | flushes output after each output operation |
| [🔗](#tab:ios.fmtflags-row-16)<br>uppercase | replaces certain lowercase letters with their uppercase equivalents in generated output |
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L1016)
Typefmtflags also defines the constants indicated in Table [137](#tab:ios.fmtflags.const "Table 137: fmtflags constants")[.](#2.sentence-1)
Table [137](#tab:ios.fmtflags.const) — fmtflags constants [[tab:ios.fmtflags.const]](./tab:ios.fmtflags.const)
| [🔗](#tab:ios.fmtflags.const-row-1)<br>**Constant** | **Allowable values** |
| --- | --- |
| [🔗](#tab:ios.fmtflags.const-row-2)<br>adjustfield | left | right | internal |
| [🔗](#tab:ios.fmtflags.const-row-3)<br>basefield | dec | oct | hex |
| [🔗](#tab:ios.fmtflags.const-row-4)<br>floatfield | scientific | fixed |

50
cppdraft/ios/init.md Normal file
View File

@@ -0,0 +1,50 @@
[ios.init]
# 31 Input/output library [[input.output]](./#input.output)
## 31.5 Iostreams base classes [[iostreams.base]](iostreams.base#ios.init)
### 31.5.2 Class ios_base [[ios.base]](ios.base#ios.init)
#### 31.5.2.2 Types [[ios.types]](ios.types#ios.init)
#### 31.5.2.2.6 Class ios_base::Init [ios.init]
[🔗](#lib:ios_base::Init)
namespace std {class ios_base::Init {public: Init();
Init(const Init&) = default; ~Init();
Init& operator=(const Init&) = default; };}
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L1139)
The class Init describes an object whose construction
ensures the construction of the eight objects declared in[<iostream>](iostream.syn#header:%3ciostream%3e "31.4.1Header <iostream> synopsis[iostream.syn]") ([[iostream.objects]](iostream.objects "31.4Standard iostream objects")) that associate file
stream buffers with the standard C streams
provided for by the functions declared in[<cstdio>](cstdio.syn#header:%3ccstdio%3e "31.13.1Header <cstdio> synopsis[cstdio.syn]")[.](#1.sentence-1)
[🔗](#lib:ios_base::Init,constructor)
`Init();
`
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L1154)
*Effects*: Constructs and initializes the objects cin, cout, cerr,clog, wcin, wcout, wcerr, and wclog if
they have not already been constructed and initialized[.](#2.sentence-1)
[🔗](#lib:ios_base::Init,destructor)
`~Init();
`
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L1167)
*Effects*: If there are no other instances of the class still in existence,
callscout.flush(),cerr.flush(),clog.flush(),wcout.flush(),wcerr.flush(),wclog.flush()[.](#3.sentence-1)

42
cppdraft/ios/iostate.md Normal file
View File

@@ -0,0 +1,42 @@
[ios.iostate]
# 31 Input/output library [[input.output]](./#input.output)
## 31.5 Iostreams base classes [[iostreams.base]](iostreams.base#ios.iostate)
### 31.5.2 Class ios_base [[ios.base]](ios.base#ios.iostate)
#### 31.5.2.2 Types [[ios.types]](ios.types#ios.iostate)
#### 31.5.2.2.3 Type ios_base::iostate [ios.iostate]
[🔗](#lib:iostate,ios_base)
`using iostate = T2;
`
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L1039)
The typeiostate is a bitmask type ([[bitmask.types]](bitmask.types "16.3.3.3.3Bitmask types"))
that contains the elements indicated in Table [138](#tab:ios.iostate "Table 138: iostate effects")[.](#1.sentence-1)
Table [138](#tab:ios.iostate) — iostate effects [[tab:ios.iostate]](./tab:ios.iostate)
| [🔗](#tab:ios.iostate-row-1)<br>**Element** | **Effect(s) if set** |
| --- | --- |
| [🔗](#tab:ios.iostate-row-2)<br>badbit | indicates a loss of integrity in an input or output sequence (such as an irrecoverable read error from a file); |
| [🔗](#tab:ios.iostate-row-3)<br>eofbit | indicates that an input operation reached the end of an input sequence; |
| [🔗](#tab:ios.iostate-row-4)<br>failbit | indicates that an input operation failed to read the expected characters, or that an output operation failed to generate the desired characters[.](#tab:ios.iostate-row-4-column-2-sentence-1) |
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L1056)
Typeiostate also defines the constant:
- [(2.1)](#2.1)
goodbit,
the value zero[.](#2.sentence-1)

View File

@@ -0,0 +1,48 @@
[ios.members.static]
# 31 Input/output library [[input.output]](./#input.output)
## 31.5 Iostreams base classes [[iostreams.base]](iostreams.base#ios.members.static)
### 31.5.2 Class ios_base [[ios.base]](ios.base#ios.members.static)
#### 31.5.2.5 Static members [ios.members.static]
[🔗](#lib:sync_with_stdio,ios_base)
`static bool sync_with_stdio(bool sync = true);
`
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L1369)
*Effects*: If any input or output operation has occurred using the standard streams prior to the
call, the effect isimplementation-defined[.](#1.sentence-1)
Otherwise, called with a false argument, it allows the standard streams to
operate independently of the standard C streams[.](#1.sentence-2)
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L1378)
*Returns*: true if the previous state of the [standard iostream objects](iostream.objects "31.4Standard iostream objects[iostream.objects]") was synchronized and otherwise returnsfalse[.](#2.sentence-1)
The first time it is called,
the function returnstrue[.](#2.sentence-2)
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L1388)
*Remarks*: When a standard iostream object str is*synchronized* with a standard stdio stream f, the effect of inserting a character c byfputc(f, c); is the same as the effect ofstr.rdbuf()->sputc(c); for any sequences of characters; the effect of extracting a character c byc = fgetc(f); is the same as the effect ofc = str.rdbuf()->sbumpc(); for any sequences of characters; and the effect of pushing back a character c byungetc(c, f); is the same as the effect ofstr.rdbuf()->sputbackc(c); for any sequence of characters[.](#3.sentence-1)[259](#footnote-259 "This implies that operations on a standard iostream object can be mixed arbitrarily with operations on the corresponding stdio stream. In practical terms, synchronization usually means that a standard iostream object and a standard stdio object share a buffer.")
[259)](#footnote-259)[259)](#footnoteref-259)
This implies that operations on a standard iostream object can be mixed arbitrarily
with operations on the corresponding stdio stream[.](#footnote-259.sentence-1)
In practical terms, synchronization
usually means that a standard iostream object and a standard stdio object share a
buffer[.](#footnote-259.sentence-2)

36
cppdraft/ios/openmode.md Normal file
View File

@@ -0,0 +1,36 @@
[ios.openmode]
# 31 Input/output library [[input.output]](./#input.output)
## 31.5 Iostreams base classes [[iostreams.base]](iostreams.base#ios.openmode)
### 31.5.2 Class ios_base [[ios.base]](ios.base#ios.openmode)
#### 31.5.2.2 Types [[ios.types]](ios.types#ios.openmode)
#### 31.5.2.2.4 Type ios_base::openmode [ios.openmode]
[🔗](#lib:openmode,ios_base)
`using openmode = T3;
`
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L1075)
The typeopenmode is a bitmask type ([[bitmask.types]](bitmask.types "16.3.3.3.3Bitmask types"))[.](#1.sentence-1)
It contains the elements indicated in Table [139](#tab:ios.openmode "Table 139: openmode effects")[.](#1.sentence-2)
Table [139](#tab:ios.openmode) — openmode effects [[tab:ios.openmode]](./tab:ios.openmode)
| [🔗](#tab:ios.openmode-row-1)<br>**Element** | **Effect(s) if set** |
| --- | --- |
| [🔗](#tab:ios.openmode-row-2)<br>app | seek to end before each write |
| [🔗](#tab:ios.openmode-row-3)<br>ate | open and seek to end immediately after opening |
| [🔗](#tab:ios.openmode-row-4)<br>binary | perform input and output in binary mode (as opposed to text mode) |
| [🔗](#tab:ios.openmode-row-5)<br>in | open for input |
| [🔗](#tab:ios.openmode-row-6)<br>noreplace | open in exclusive mode |
| [🔗](#tab:ios.openmode-row-7)<br>out | open for output |
| [🔗](#tab:ios.openmode-row-8)<br>trunc | truncate an existing stream when opening |

31
cppdraft/ios/overview.md Normal file
View File

@@ -0,0 +1,31 @@
[ios.overview]
# 31 Input/output library [[input.output]](./#input.output)
## 31.5 Iostreams base classes [[iostreams.base]](iostreams.base#ios.overview)
### 31.5.4 Class template basic_ios [[ios]](ios#overview)
#### 31.5.4.1 Overview [ios.overview]
[🔗](#lib:basic_ios)
namespace std {template<class charT, class traits = char_traits<charT>>class basic_ios : public ios_base {public:using char_type = charT; using int_type = typename traits::int_type; using pos_type = typename traits::pos_type; using off_type = typename traits::off_type; using traits_type = traits; // [[iostate.flags]](iostate.flags "31.5.4.4Flags functions"), flags functionsexplicit operator bool() const; bool operator!() const;
iostate rdstate() const; void clear(iostate state = goodbit); void setstate(iostate state); bool good() const; bool eof() const; bool fail() const; bool bad() const;
iostate exceptions() const; void exceptions(iostate except); // [[basic.ios.cons]](basic.ios.cons "31.5.4.2Constructors"), constructor/destructorexplicit basic_ios(basic_streambuf<charT, traits>* sb); virtual ~basic_ios(); // [[basic.ios.members]](basic.ios.members "31.5.4.3Member functions"), members basic_ostream<charT, traits>* tie() const;
basic_ostream<charT, traits>* tie(basic_ostream<charT, traits>* tiestr);
basic_streambuf<charT, traits>* rdbuf() const;
basic_streambuf<charT, traits>* rdbuf(basic_streambuf<charT, traits>* sb);
basic_ios& copyfmt(const basic_ios& rhs);
char_type fill() const;
char_type fill(char_type ch);
locale imbue(const locale& loc); char narrow(char_type c, char dfault) const;
char_type widen(char c) const;
basic_ios(const basic_ios&) = delete;
basic_ios& operator=(const basic_ios&) = delete; protected: basic_ios(); void init(basic_streambuf<charT, traits>* sb); void move(basic_ios& rhs); void move(basic_ios&& rhs); void swap(basic_ios& rhs) noexcept; void set_rdbuf(basic_streambuf<charT, traits>* sb); };}

31
cppdraft/ios/seekdir.md Normal file
View File

@@ -0,0 +1,31 @@
[ios.seekdir]
# 31 Input/output library [[input.output]](./#input.output)
## 31.5 Iostreams base classes [[iostreams.base]](iostreams.base#ios.seekdir)
### 31.5.2 Class ios_base [[ios.base]](ios.base#ios.seekdir)
#### 31.5.2.2 Types [[ios.types]](ios.types#ios.seekdir)
#### 31.5.2.2.5 Type ios_base::seekdir [ios.seekdir]
[🔗](#lib:seekdir,ios_base)
`using seekdir = T4;
`
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L1107)
The typeseekdir is an enumerated type ([[enumerated.types]](enumerated.types "16.3.3.3.2Enumerated types"))
that contains the elements indicated in Table [140](#tab:ios.seekdir "Table 140: seekdir effects")[.](#1.sentence-1)
Table [140](#tab:ios.seekdir) — seekdir effects [[tab:ios.seekdir]](./tab:ios.seekdir)
| [🔗](#tab:ios.seekdir-row-1)<br>**Element** | **Meaning** |
| --- | --- |
| [🔗](#tab:ios.seekdir-row-2)<br>beg | request a seek (for subsequent input or output) relative to the beginning of the stream |
| [🔗](#tab:ios.seekdir-row-3)<br>cur | request a seek relative to the current position within the sequence |
| [🔗](#tab:ios.seekdir-row-4)<br>end | request a seek relative to the current end of the sequence |

39
cppdraft/ios/syn.md Normal file
View File

@@ -0,0 +1,39 @@
[ios.syn]
# 31 Input/output library [[input.output]](./#input.output)
## 31.5 Iostreams base classes [[iostreams.base]](iostreams.base#ios.syn)
### 31.5.1 Header <ios> synopsis [ios.syn]
[🔗](#header:%3cios%3e)
#include <iosfwd> // see [[iosfwd.syn]](iosfwd.syn "31.3.1Header <iosfwd> synopsis")namespace std {// [[stream.types]](stream.types "31.2.2Types"), typesusing streamoff = *implementation-defined*; using streamsize = *implementation-defined*; // [[fpos]](fpos "31.5.3Class template fpos"), class template fpostemplate<class stateT> class fpos; // [[ios.base]](ios.base "31.5.2Class ios_­base"), class ios_baseclass ios_base; // [[ios]](ios "31.5.4Class template basic_­ios"), class template basic_iostemplate<class charT, class traits = char_traits<charT>>class basic_ios; // [[std.ios.manip]](std.ios.manip "31.5.5ios_­base manipulators"), manipulators ios_base& boolalpha (ios_base& str);
ios_base& noboolalpha(ios_base& str);
ios_base& showbase (ios_base& str);
ios_base& noshowbase (ios_base& str);
ios_base& showpoint (ios_base& str);
ios_base& noshowpoint(ios_base& str);
ios_base& showpos (ios_base& str);
ios_base& noshowpos (ios_base& str);
ios_base& skipws (ios_base& str);
ios_base& noskipws (ios_base& str);
ios_base& uppercase (ios_base& str);
ios_base& nouppercase(ios_base& str);
ios_base& unitbuf (ios_base& str);
ios_base& nounitbuf (ios_base& str); // [[adjustfield.manip]](adjustfield.manip "31.5.5.2adjustfield manipulators"), adjustfield ios_base& internal (ios_base& str);
ios_base& left (ios_base& str);
ios_base& right (ios_base& str); // [[basefield.manip]](basefield.manip "31.5.5.3basefield manipulators"), basefield ios_base& dec (ios_base& str);
ios_base& hex (ios_base& str);
ios_base& oct (ios_base& str); // [[floatfield.manip]](floatfield.manip "31.5.5.4floatfield manipulators"), floatfield ios_base& fixed (ios_base& str);
ios_base& scientific (ios_base& str);
ios_base& hexfloat (ios_base& str);
ios_base& defaultfloat(ios_base& str); // [[error.reporting]](error.reporting "31.5.6Error reporting"), error reportingenum class [io_errc](#lib:io_errc "31.5.1Header <ios> synopsis[ios.syn]") {[stream](#lib:io_errc,stream "31.5.1Header <ios> synopsis[ios.syn]") = 1}; template<> struct is_error_code_enum<io_errc> : public true_type { };
error_code make_error_code(io_errc e) noexcept;
error_condition make_error_condition(io_errc e) noexcept; const error_category& iostream_category() noexcept;}

246
cppdraft/ios/types.md Normal file
View File

@@ -0,0 +1,246 @@
[ios.types]
# 31 Input/output library [[input.output]](./#input.output)
## 31.5 Iostreams base classes [[iostreams.base]](iostreams.base#ios.types)
### 31.5.2 Class ios_base [[ios.base]](ios.base#ios.types)
#### 31.5.2.2 Types [ios.types]
#### [31.5.2.2.1](#ios.failure) Class ios_base::failure [[ios.failure]](ios.failure)
[🔗](#lib:ios_base::failure)
namespace std {class ios_base::failure : public system_error {public:explicit failure(const string& msg, const error_code& ec = io_errc::stream); explicit failure(const char* msg, const error_code& ec = io_errc::stream); };}
[1](#ios.failure-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L919)
An implementation is permitted to define ios_base::failure as a synonym for a class with equivalent functionality
to class ios_base::failure shown in this subclause[.](#ios.failure-1.sentence-1)
[*Note [1](#ios.failure-note-1)*:
When ios_base::failure is a synonym for another type,
that type needs to provide a nested type failure to emulate the injected-class-name[.](#ios.failure-1.sentence-2)
— *end note*]
The classfailure defines the base class
for the types of all objects thrown as exceptions,
by functions in the iostreams library,
to report errors detected during stream buffer operations[.](#ios.failure-1.sentence-3)
[2](#ios.failure-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L935)
When throwing ios_base::failure exceptions, implementations should provide
values of ec that identify the specific reason for the failure[.](#ios.failure-2.sentence-1)
[*Note [2](#ios.failure-note-2)*:
Errors arising from the operating system would typically be reported assystem_category() errors with an error value of the error number
reported by the operating system[.](#ios.failure-2.sentence-2)
Errors arising from within the stream library would
typically be reported as error_code(io_errc::stream,
iostream_category())[.](#ios.failure-2.sentence-3)
— *end note*]
[🔗](#lib:ios_base::failure,constructor)
`explicit failure(const string& msg, const error_code& ec = io_errc::stream);
`
[3](#ios.failure-3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L952)
*Effects*: Constructs the base class with msg and ec[.](#ios.failure-3.sentence-1)
[🔗](#lib:ios_base::failure,constructor_)
`explicit failure(const char* msg, const error_code& ec = io_errc::stream);
`
[4](#ios.failure-4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L963)
*Effects*: Constructs the base class with msg and ec[.](#ios.failure-4.sentence-1)
#### [31.5.2.2.2](#ios.fmtflags) Type ios_base::fmtflags [[ios.fmtflags]](ios.fmtflags)
[🔗](#lib:fmtflags,ios_base)
`using fmtflags = T1;
`
[1](#ios.fmtflags-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L976)
The typefmtflags is a bitmask type ([[bitmask.types]](bitmask.types "16.3.3.3.3Bitmask types"))[.](#ios.fmtflags-1.sentence-1)
Setting its elements has the effects indicated in Table [136](#tab:ios.fmtflags "Table 136: fmtflags effects")[.](#ios.fmtflags-1.sentence-2)
Table [136](#tab:ios.fmtflags) — fmtflags effects [[tab:ios.fmtflags]](./tab:ios.fmtflags)
| [🔗](#tab:ios.fmtflags-row-1)<br>**Element** | **Effect(s) if set** |
| --- | --- |
| [🔗](#tab:ios.fmtflags-row-2)<br>boolalpha | insert and extract bool type in alphabetic format |
| [🔗](#tab:ios.fmtflags-row-3)<br>dec | converts integer input or generates integer output in decimal base |
| [🔗](#tab:ios.fmtflags-row-4)<br>fixed | generate floating-point output in fixed-point notation |
| [🔗](#tab:ios.fmtflags-row-5)<br>hex | converts integer input or generates integer output in hexadecimal base |
| [🔗](#tab:ios.fmtflags-row-6)<br>internal | adds fill characters at a designated internal point in certain generated output, or identical to right if no such point is designated |
| [🔗](#tab:ios.fmtflags-row-7)<br>left | adds fill characters on the right (final positions) of certain generated output |
| [🔗](#tab:ios.fmtflags-row-8)<br>oct | converts integer input or generates integer output in octal base |
| [🔗](#tab:ios.fmtflags-row-9)<br>right | adds fill characters on the left (initial positions) of certain generated output |
| [🔗](#tab:ios.fmtflags-row-10)<br>scientific | generates floating-point output in scientific notation |
| [🔗](#tab:ios.fmtflags-row-11)<br>showbase | generates a prefix indicating the numeric base of generated integer output |
| [🔗](#tab:ios.fmtflags-row-12)<br>showpoint | generates a decimal-point character unconditionally in generated floating-point output |
| [🔗](#tab:ios.fmtflags-row-13)<br>showpos | generates a + sign in non-negative generated numeric output |
| [🔗](#tab:ios.fmtflags-row-14)<br>skipws | skips leading whitespace before certain input operations |
| [🔗](#tab:ios.fmtflags-row-15)<br>unitbuf | flushes output after each output operation |
| [🔗](#tab:ios.fmtflags-row-16)<br>uppercase | replaces certain lowercase letters with their uppercase equivalents in generated output |
[2](#ios.fmtflags-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L1016)
Typefmtflags also defines the constants indicated in Table [137](#tab:ios.fmtflags.const "Table 137: fmtflags constants")[.](#ios.fmtflags-2.sentence-1)
Table [137](#tab:ios.fmtflags.const) — fmtflags constants [[tab:ios.fmtflags.const]](./tab:ios.fmtflags.const)
| [🔗](#tab:ios.fmtflags.const-row-1)<br>**Constant** | **Allowable values** |
| --- | --- |
| [🔗](#tab:ios.fmtflags.const-row-2)<br>adjustfield | left | right | internal |
| [🔗](#tab:ios.fmtflags.const-row-3)<br>basefield | dec | oct | hex |
| [🔗](#tab:ios.fmtflags.const-row-4)<br>floatfield | scientific | fixed |
#### [31.5.2.2.3](#ios.iostate) Type ios_base::iostate [[ios.iostate]](ios.iostate)
[🔗](#lib:iostate,ios_base)
`using iostate = T2;
`
[1](#ios.iostate-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L1039)
The typeiostate is a bitmask type ([[bitmask.types]](bitmask.types "16.3.3.3.3Bitmask types"))
that contains the elements indicated in Table [138](#tab:ios.iostate "Table 138: iostate effects")[.](#ios.iostate-1.sentence-1)
Table [138](#tab:ios.iostate) — iostate effects [[tab:ios.iostate]](./tab:ios.iostate)
| [🔗](#tab:ios.iostate-row-1)<br>**Element** | **Effect(s) if set** |
| --- | --- |
| [🔗](#tab:ios.iostate-row-2)<br>badbit | indicates a loss of integrity in an input or output sequence (such as an irrecoverable read error from a file); |
| [🔗](#tab:ios.iostate-row-3)<br>eofbit | indicates that an input operation reached the end of an input sequence; |
| [🔗](#tab:ios.iostate-row-4)<br>failbit | indicates that an input operation failed to read the expected characters, or that an output operation failed to generate the desired characters[.](#tab:ios.iostate-row-4-column-2-sentence-1) |
[2](#ios.iostate-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L1056)
Typeiostate also defines the constant:
- [(2.1)](#ios.iostate-2.1)
goodbit,
the value zero[.](#ios.iostate-2.sentence-1)
#### [31.5.2.2.4](#ios.openmode) Type ios_base::openmode [[ios.openmode]](ios.openmode)
[🔗](#lib:openmode,ios_base)
`using openmode = T3;
`
[1](#ios.openmode-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L1075)
The typeopenmode is a bitmask type ([[bitmask.types]](bitmask.types "16.3.3.3.3Bitmask types"))[.](#ios.openmode-1.sentence-1)
It contains the elements indicated in Table [139](#tab:ios.openmode "Table 139: openmode effects")[.](#ios.openmode-1.sentence-2)
Table [139](#tab:ios.openmode) — openmode effects [[tab:ios.openmode]](./tab:ios.openmode)
| [🔗](#tab:ios.openmode-row-1)<br>**Element** | **Effect(s) if set** |
| --- | --- |
| [🔗](#tab:ios.openmode-row-2)<br>app | seek to end before each write |
| [🔗](#tab:ios.openmode-row-3)<br>ate | open and seek to end immediately after opening |
| [🔗](#tab:ios.openmode-row-4)<br>binary | perform input and output in binary mode (as opposed to text mode) |
| [🔗](#tab:ios.openmode-row-5)<br>in | open for input |
| [🔗](#tab:ios.openmode-row-6)<br>noreplace | open in exclusive mode |
| [🔗](#tab:ios.openmode-row-7)<br>out | open for output |
| [🔗](#tab:ios.openmode-row-8)<br>trunc | truncate an existing stream when opening |
#### [31.5.2.2.5](#ios.seekdir) Type ios_base::seekdir [[ios.seekdir]](ios.seekdir)
[🔗](#lib:seekdir,ios_base)
`using seekdir = T4;
`
[1](#ios.seekdir-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L1107)
The typeseekdir is an enumerated type ([[enumerated.types]](enumerated.types "16.3.3.3.2Enumerated types"))
that contains the elements indicated in Table [140](#tab:ios.seekdir "Table 140: seekdir effects")[.](#ios.seekdir-1.sentence-1)
Table [140](#tab:ios.seekdir) — seekdir effects [[tab:ios.seekdir]](./tab:ios.seekdir)
| [🔗](#tab:ios.seekdir-row-1)<br>**Element** | **Meaning** |
| --- | --- |
| [🔗](#tab:ios.seekdir-row-2)<br>beg | request a seek (for subsequent input or output) relative to the beginning of the stream |
| [🔗](#tab:ios.seekdir-row-3)<br>cur | request a seek relative to the current position within the sequence |
| [🔗](#tab:ios.seekdir-row-4)<br>end | request a seek relative to the current end of the sequence |
#### [31.5.2.2.6](#ios.init) Class ios_base::Init [[ios.init]](ios.init)
[🔗](#lib:ios_base::Init)
namespace std {class ios_base::Init {public: Init();
Init(const Init&) = default; ~Init();
Init& operator=(const Init&) = default; };}
[1](#ios.init-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L1139)
The class Init describes an object whose construction
ensures the construction of the eight objects declared in[<iostream>](iostream.syn#header:%3ciostream%3e "31.4.1Header <iostream> synopsis[iostream.syn]") ([[iostream.objects]](iostream.objects "31.4Standard iostream objects")) that associate file
stream buffers with the standard C streams
provided for by the functions declared in[<cstdio>](cstdio.syn#header:%3ccstdio%3e "31.13.1Header <cstdio> synopsis[cstdio.syn]")[.](#ios.init-1.sentence-1)
[🔗](#lib:ios_base::Init,constructor)
`Init();
`
[2](#ios.init-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L1154)
*Effects*: Constructs and initializes the objects cin, cout, cerr,clog, wcin, wcout, wcerr, and wclog if
they have not already been constructed and initialized[.](#ios.init-2.sentence-1)
[🔗](#lib:ios_base::Init,destructor)
`~Init();
`
[3](#ios.init-3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L1167)
*Effects*: If there are no other instances of the class still in existence,
callscout.flush(),cerr.flush(),clog.flush(),wcout.flush(),wcerr.flush(),wclog.flush()[.](#ios.init-3.sentence-1)