Difference between revisions of "cpp/io/ios base"
m (actually, pword/iword storage is not necessarily two arrays, not in gcc for example) |
(Added LWG issue #1357 DR.) |
||
(20 intermediate revisions by 6 users not shown) | |||
Line 1: | Line 1: | ||
{{cpp/title|ios_base}} | {{cpp/title|ios_base}} | ||
− | {{cpp/io/ios_base/ | + | {{cpp/io/ios_base/navbar}} |
− | {{ddcl | header=ios | | + | {{ddcl|header=ios| |
class ios_base; | class ios_base; | ||
}} | }} | ||
Line 7: | Line 7: | ||
The class {{tt|ios_base}} is a multipurpose class that serves as the base class for all I/O stream classes. It maintains several kinds of data: | The class {{tt|ios_base}} is a multipurpose class that serves as the base class for all I/O stream classes. It maintains several kinds of data: | ||
− | + | @1@ state information: stream status flags. | |
− | + | @2@ control information: flags that control formatting of both input and output sequences and the imbued locale. | |
− | + | @3@ private storage: indexed extensible data structure that allows both {{c/core|long}} and {{c/core|void*}} members, which may be implemented as two arbitrary-length arrays or a single array of two-element structs or another container. | |
− | + | @4@ callbacks: arbitrary number of user-defined functions to be called from {{ltf|cpp/io/ios_base/imbue}}, {{lc|std::basic_ios::copyfmt()}}, and {{ltf|cpp/io/ios_base/~ios_base}}. | |
− | + | ||
− | {{ | + | |
− | Typical implementation holds member constants corresponding to all values of fmtflags, iostate, openmode, and seekdir shown below, member variables to maintain current precision, width, formatting flags, exception mask, buffer error state, a resizeable container holding the callbacks, the currently imbued locale, | + | Typical implementation holds member constants corresponding to all values of {{ltt|cpp/io/ios_base/fmtflags}}, {{ltt|cpp/io/ios_base/iostate}}, {{ltt|cpp/io/ios_base/openmode}}, and {{ltt|cpp/io/ios_base/seekdir}} shown below, member variables to maintain current precision, width, and formatting flags, the exception mask, the buffer error state, a resizeable container holding the callbacks, the currently imbued locale, the private storage, and a static integer variable for {{ltf|cpp/io/ios_base/xalloc}}. |
===Member functions=== | ===Member functions=== | ||
− | {{ | + | {{dsc begin}} |
− | {{ | + | {{dsc inc|cpp/io/ios_base/dsc constructor}} |
− | {{ | + | {{dsc inc|cpp/io/ios_base/dsc destructor}} |
+ | {{dsc inc|cpp/io/ios_base/dsc operator{{=}}}} | ||
− | {{ | + | {{dsc h2|Formatting}} |
− | {{ | + | {{dsc inc|cpp/io/ios_base/dsc flags}} |
− | {{ | + | {{dsc inc|cpp/io/ios_base/dsc setf}} |
− | {{ | + | {{dsc inc|cpp/io/ios_base/dsc unsetf}} |
− | {{ | + | {{dsc inc|cpp/io/ios_base/dsc precision}} |
− | {{ | + | {{dsc inc|cpp/io/ios_base/dsc width}} |
− | {{ | + | {{dsc h2|Locales}} |
− | {{ | + | {{dsc inc|cpp/io/ios_base/dsc imbue}} |
− | {{ | + | {{dsc inc|cpp/io/ios_base/dsc getloc}} |
− | {{ | + | {{dsc h2|Internal extensible array}} |
− | {{ | + | {{dsc inc|cpp/io/ios_base/dsc xalloc}} |
− | {{ | + | {{dsc inc|cpp/io/ios_base/dsc iword}} |
− | {{ | + | {{dsc inc|cpp/io/ios_base/dsc pword}} |
− | {{ | + | {{dsc h2|Miscellaneous}} |
− | {{ | + | {{dsc inc|cpp/io/ios_base/dsc register_callback}} |
− | {{ | + | {{dsc inc|cpp/io/ios_base/dsc sync_with_stdio}} |
− | {{ | + | {{dsc h1|Member classes}} |
− | {{ | + | {{dsc inc|cpp/io/ios_base/dsc failure}} |
− | {{ | + | {{dsc inc|cpp/io/ios_base/dsc Init}} |
− | {{ | + | {{dsc end}} |
− | {{ | + | {{dsc begin}} |
− | {{ | + | {{dsc h1|Member types and constants}} |
− | {{ | + | {{dsc hitem|Type|Explanation}} |
− | {{ | + | {{dsc inc|cpp/io/ios_base/dsc openmode}} |
− | {{ | + | {{dsc inc|cpp/io/ios_base/dsc fmtflags}} |
− | {{ | + | {{dsc inc|cpp/io/ios_base/dsc iostate}} |
− | {{ | + | {{dsc inc|cpp/io/ios_base/dsc seekdir}} |
− | {{ | + | {{dsc inc|cpp/io/ios_base/dsc event}} |
− | {{ | + | {{dsc inc|cpp/io/ios_base/dsc event_callback}} |
− | {{ | + | {{dsc end}} |
− | {{ | + | {{rev begin}} |
− | {{ | + | {{rev|until=c++17| |
− | {{ | + | {{dsc begin}} |
− | {{ | + | {{dsc h2|Deprecated member types}} |
− | {{ | + | {{dsc hitem|Type|Explanation}} |
− | {{ | + | {{dsc|{{tt|io_state}} {{mark deprecated}}|integer type that may be used like {{tt|iostate}}}} |
− | {{ | + | {{dsc|{{tt|open_mode}} {{mark deprecated}}|integer type that may be used like {{tt|openmode}}}} |
+ | {{dsc|{{tt|seek_dir}} {{mark deprecated}}|integer type that may be used like {{tt|seekdir}}}} | ||
+ | {{dsc|{{tt|streamoff}} {{mark deprecated}}|unspecified type that may be used like {{tt|off_type}}, not necessarily {{lc|std::streamoff}}}} | ||
+ | {{dsc|{{tt|streampos}} {{mark deprecated}}|unspecified type that may be used like {{tt|pos_type}}, not necessarily {{lc|std::streampos}}}} | ||
+ | {{dsc end}} | ||
+ | }} | ||
+ | {{rev end}} | ||
+ | |||
+ | ===Defect reports=== | ||
+ | {{dr list begin}} | ||
+ | {{dr list item|wg=lwg|dr=1357|paper=N3110|std=C++98|before={{tt|std::ios_base}} defined {{c/core|operator~}}, {{c/core|operator&}}<br>and {{c/core|operator{{!}}}} for types {{tt|openmode}}, {{tt|fmtflags}} and<br>{{tt|iostate}}, violating the requirements of {{named req|BitmaskType}}<ref>A {{named req|BitmaskType}} needs to support bitwise opertaions on its own. The bitwise operation support should not be provided externally.</ref>|after=removed these definitions}} | ||
+ | {{dr list end}} | ||
+ | <references/> | ||
+ | |||
+ | ===See also=== | ||
+ | {{dsc begin}} | ||
+ | {{dsc inc|cpp/io/dsc basic_ios}} | ||
+ | {{dsc end}} | ||
+ | |||
+ | {{langlinks|de|es|fr|it|ja|pt|ru|zh}} |
Latest revision as of 21:38, 3 August 2023
Defined in header <ios>
|
||
class ios_base; |
||
The class ios_base
is a multipurpose class that serves as the base class for all I/O stream classes. It maintains several kinds of data:
Typical implementation holds member constants corresponding to all values of fmtflags, iostate, openmode, and seekdir shown below, member variables to maintain current precision, width, and formatting flags, the exception mask, the buffer error state, a resizeable container holding the callbacks, the currently imbued locale, the private storage, and a static integer variable for xalloc().
Contents |
[edit] Member functions
constructs the object (protected member function) | |
[virtual] |
destructs the object (virtual public member function) |
assigns to the stream (public member function) | |
Formatting | |
manages format flags (public member function) | |
sets specific format flag (public member function) | |
clears specific format flag (public member function) | |
manages decimal precision of floating point operations (public member function) | |
manages field width (public member function) | |
Locales | |
sets locale (public member function) | |
returns current locale (public member function) | |
Internal extensible array | |
[static] |
returns a program-wide unique integer that is safe to use as index to pword() and iword() (public static member function) |
resizes the private storage if necessary and access to the long element at the given index (public member function) | |
resizes the private storage if necessary and access to the void* element at the given index (public member function) | |
Miscellaneous | |
registers event callback function (public member function) | |
[static] |
sets whether C++ and C I/O libraries are interoperable (public static member function) |
Member classes | |
stream exception (public member class) | |
initializes standard stream objects (public member class) |
Member types and constants | |||||||||||||||||||||||||||||||||||||||
Type | Explanation | ||||||||||||||||||||||||||||||||||||||
stream open mode type
The following constants are also defined:
(typedef) | |||||||||||||||||||||||||||||||||||||||
formatting flags type
The following constants are also defined:
(typedef) | |||||||||||||||||||||||||||||||||||||||
state of the stream type
The following constants are also defined:
(typedef) | |||||||||||||||||||||||||||||||||||||||
seeking direction type
The following constants are also defined:
(typedef) | |||||||||||||||||||||||||||||||||||||||
specifies event type (enum) | |||||||||||||||||||||||||||||||||||||||
callback function type (typedef) |
|
(until C++17) |
[edit] Defect reports
The following behavior-changing defect reports were applied retroactively to previously published C++ standards.
DR | Applied to | Behavior as published | Correct behavior |
---|---|---|---|
LWG 1357 (N3110) |
C++98 | std::ios_base defined operator~, operator&and operator| for types openmode , fmtflags andiostate , violating the requirements of BitmaskType[1]
|
removed these definitions |
- ↑ A BitmaskType needs to support bitwise opertaions on its own. The bitwise operation support should not be provided externally.
[edit] See also
manages an arbitrary stream buffer (class template) |