Files
cppdraft_translate/cppdraft/iostreams/base.md
2025-10-25 03:02:53 +03:00

1911 lines
75 KiB
Markdown
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

[iostreams.base]
# 31 Input/output library [[input.output]](./#input.output)
## 31.5 Iostreams base classes [iostreams.base]
### [31.5.1](#ios.syn) Header <ios> synopsis [[ios.syn]](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;}
### [31.5.2](#ios.base) Class ios_base [[ios.base]](ios.base)
#### [31.5.2.1](#ios.base.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]](#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](#ios.base.general-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L854)
ios_base defines several member types:
- [(1.1)](#ios.base.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)](#ios.base.general-1.2)
a class Init;
- [(1.3)](#ios.base.general-1.3)
three bitmask types, fmtflags, iostate, and openmode;
- [(1.4)](#ios.base.general-1.4)
an enumerated type, seekdir[.](#ios.base.general-1.sentence-1)
[2](#ios.base.general-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L868)
It maintains several kinds of data:
- [(2.1)](#ios.base.general-2.1)
state information that reflects the integrity of the stream buffer;
- [(2.2)](#ios.base.general-2.2)
control information that influences how to interpret (format) input
sequences and how to generate (format) output sequences;
- [(2.3)](#ios.base.general-2.3)
additional information that is stored by the program for its private use[.](#ios.base.general-2.sentence-1)
[3](#ios.base.general-3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L880)
[*Note [1](#ios.base.general-note-1)*:
For the sake of exposition, the maintained data is presented here as:
- [(3.1)](#ios.base.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)](#ios.base.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)](#ios.base.general-3.3)
void** *parray*,
points to the first element of an
arbitrary-length pointer array maintained for the private use of the program[.](#ios.base.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](#ios.base.locales) Functions [[ios.base.locales]](ios.base.locales)
[🔗](#lib:imbue,ios_base)
`locale imbue(const locale& loc);
`
[1](#ios.base.locales-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[.](#ios.base.locales-1.sentence-1)
[2](#ios.base.locales-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L1336)
*Postconditions*: loc == getloc()[.](#ios.base.locales-2.sentence-1)
[3](#ios.base.locales-3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L1340)
*Returns*: The previous value ofgetloc()[.](#ios.base.locales-3.sentence-1)
[🔗](#lib:getloc,ios_base)
`locale getloc() const;
`
[4](#ios.base.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[.](#ios.base.locales-4.sentence-1)
Otherwise, returns the imbued locale, to be used to
perform locale-dependent input and output operations[.](#ios.base.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](#ios.base.storage) Storage functions [[ios.base.storage]](ios.base.storage)
[🔗](#lib:xalloc,ios_base)
`static int xalloc();
`
[1](#ios.base.storage-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L1433)
*Returns*: *index*++[.](#ios.base.storage-1.sentence-1)
[2](#ios.base.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]")[.](#ios.base.storage-2.sentence-1)
[🔗](#lib:iword,ios_base)
`long& iword(int idx);
`
[3](#ios.base.storage-3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L1450)
*Preconditions*: idx is a value obtained by a call to xalloc[.](#ios.base.storage-3.sentence-1)
[4](#ios.base.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*[.](#ios.base.storage-4.sentence-1)
The function then extends the array pointed at by*iarray* as necessary to include the element*iarray*[idx][.](#ios.base.storage-4.sentence-2)
Each newly allocated element of the array is initialized to zero[.](#ios.base.storage-4.sentence-3)
The reference returned is invalid after any other operation on the
object[.](#ios.base.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[.](#ios.base.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)[.](#ios.base.storage-4.sentence-6)
[5](#ios.base.storage-5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L1491)
*Returns*: On success*iarray*[idx][.](#ios.base.storage-5.sentence-1)
On failure, a validlong& initialized to 0[.](#ios.base.storage-5.sentence-2)
[🔗](#lib:pword,ios_base)
`void*& pword(int idx);
`
[6](#ios.base.storage-6)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L1506)
*Preconditions*: idx is a value obtained by a call to xalloc[.](#ios.base.storage-6.sentence-1)
[7](#ios.base.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*[.](#ios.base.storage-7.sentence-1)
The function then extends the array
pointed at by *parray* as necessary to include the element*parray*[idx][.](#ios.base.storage-7.sentence-2)
Each newly allocated element of the array is initialized to a null
pointer[.](#ios.base.storage-7.sentence-3)
The reference returned is invalid after any other operation on the
object[.](#ios.base.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[.](#ios.base.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)[.](#ios.base.storage-7.sentence-6)
[8](#ios.base.storage-8)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L1542)
*Returns*: On successparray[idx][.](#ios.base.storage-8.sentence-1)
On failure a validvoid*& initialized to 0[.](#ios.base.storage-8.sentence-2)
[9](#ios.base.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[.](#ios.base.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](#ios.base.callback) Callbacks [[ios.base.callback]](ios.base.callback)
[🔗](#lib:register_callback,ios_base)
`void register_callback(event_callback fn, int idx);
`
[1](#ios.base.callback-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L1565)
*Preconditions*: The functionfn does not throw exceptions[.](#ios.base.callback-1.sentence-1)
[2](#ios.base.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]](#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[.](#ios.base.callback-2.sentence-1)
Functions registered are called when an event occurs, in opposite order of
registration[.](#ios.base.callback-2.sentence-2)
Functions registered while a callback function is active are not called until the next event[.](#ios.base.callback-2.sentence-3)
[3](#ios.base.callback-3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L1588)
*Remarks*: Identical pairs are not merged[.](#ios.base.callback-3.sentence-1)
A function registered twice will be called twice[.](#ios.base.callback-3.sentence-2)
#### [31.5.2.8](#ios.base.cons) Constructors and destructor [[ios.base.cons]](ios.base.cons)
[🔗](#lib:ios_base,constructor)
`ios_base();
`
[1](#ios.base.cons-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L1602)
*Effects*: Eachios_base member has an indeterminate value after construction[.](#ios.base.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[.](#ios.base.cons-1.sentence-2)
[🔗](#lib:ios_base,destructor)
`~ios_base();
`
[2](#ios.base.cons-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[.](#ios.base.cons-2.sentence-1)
Then, any memory obtained is deallocated[.](#ios.base.cons-2.sentence-2)
### [31.5.3](#fpos) Class template fpos [[fpos]](fpos)
#### [31.5.3.1](#fpos.general) General [[fpos.general]](fpos.general)
[🔗](#lib:fpos_)
namespace std {template<class stateT> class fpos {public:// [[fpos.members]](#fpos.members "31.5.3.2Members"), members stateT state() const; void state(stateT); private: stateT *st*; // *exposition only*};}
#### [31.5.3.2](#fpos.members) Members [[fpos.members]](fpos.members)
[🔗](#lib:state,fpos)
`void state(stateT s);
`
[1](#fpos.members-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L1659)
*Effects*: Assigns s to *st*[.](#fpos.members-1.sentence-1)
[🔗](#lib:state,fpos_)
`stateT state() const;
`
[2](#fpos.members-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L1670)
*Returns*: Current value of *st*[.](#fpos.members-2.sentence-1)
#### [31.5.3.3](#fpos.operations) Requirements [[fpos.operations]](fpos.operations)
[1](#fpos.operations-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L1677)
An fpos type specifies file position information[.](#fpos.operations-1.sentence-1)
It holds a state object
whose type is equal to the template parameter stateT[.](#fpos.operations-1.sentence-2)
Type stateT shall meet
the [*Cpp17DefaultConstructible*](utility.arg.requirements#:Cpp17DefaultConstructible "16.4.4.2Template argument requirements[utility.arg.requirements]") (Table [30](utility.arg.requirements#tab:cpp17.defaultconstructible "Table 30: Cpp17DefaultConstructible requirements")),[*Cpp17CopyConstructible*](utility.arg.requirements#:Cpp17CopyConstructible "16.4.4.2Template argument requirements[utility.arg.requirements]") (Table [32](utility.arg.requirements#tab:cpp17.copyconstructible "Table 32: Cpp17CopyConstructible requirements (in addition to Cpp17MoveConstructible)")),[*Cpp17CopyAssignable*](utility.arg.requirements#:Cpp17CopyAssignable "16.4.4.2Template argument requirements[utility.arg.requirements]") (Table [34](utility.arg.requirements#tab:cpp17.copyassignable "Table 34: Cpp17CopyAssignable requirements (in addition to Cpp17MoveAssignable)")), and[*Cpp17Destructible*](utility.arg.requirements#:Cpp17Destructible "16.4.4.2Template argument requirements[utility.arg.requirements]") (Table [35](utility.arg.requirements#tab:cpp17.destructible "Table 35: Cpp17Destructible requirements")) requirements[.](#fpos.operations-1.sentence-3)
If is_trivially_copy_constructible_v<stateT> is true,
then fpos<stateT> has a trivial copy constructor[.](#fpos.operations-1.sentence-4)
If is_trivially_copy_assignable_v<stateT> is true,
then fpos<stateT> has a trivial copy assignment operator[.](#fpos.operations-1.sentence-5)
If is_trivially_destructible_v<stateT> is true,
then fpos<stateT> has a trivial destructor[.](#fpos.operations-1.sentence-6)
All specializations of fpos meet
the [*Cpp17DefaultConstructible*](utility.arg.requirements#:Cpp17DefaultConstructible "16.4.4.2Template argument requirements[utility.arg.requirements]"),[*Cpp17CopyConstructible*](utility.arg.requirements#:Cpp17CopyConstructible "16.4.4.2Template argument requirements[utility.arg.requirements]"),[*Cpp17CopyAssignable*](utility.arg.requirements#:Cpp17CopyAssignable "16.4.4.2Template argument requirements[utility.arg.requirements]"),[*Cpp17Destructible*](utility.arg.requirements#:Cpp17Destructible "16.4.4.2Template argument requirements[utility.arg.requirements]"),
and [*Cpp17EqualityComparable*](utility.arg.requirements#:Cpp17EqualityComparable "16.4.4.2Template argument requirements[utility.arg.requirements]") (Table [28](utility.arg.requirements#tab:cpp17.equalitycomparable "Table 28: Cpp17EqualityComparable requirements")) requirements[.](#fpos.operations-1.sentence-7)
In addition, the expressions shown in Table [141](#tab:fpos.operations "Table 141: Position type requirements") are valid and have the indicated semantics[.](#fpos.operations-1.sentence-8)
In that table,
- [(1.1)](#fpos.operations-1.1)
P refers to a specialization of fpos,
- [(1.2)](#fpos.operations-1.2)
p and q refer to values
of type P or const P,
- [(1.3)](#fpos.operations-1.3)
pl and ql refer to modifiable lvalues of type P,
- [(1.4)](#fpos.operations-1.4)
O refers to type streamoff, and
- [(1.5)](#fpos.operations-1.5)
o and o2 refer to values
of type streamoff or const streamoff[.](#fpos.operations-1.sentence-9)
Table [141](#tab:fpos.operations) — Position type requirements [[tab:fpos.operations]](./tab:fpos.operations)
| [🔗](#tab:fpos.operations-row-1)<br>**Expression** | **Return type** | **Operational** | **Assertion/note** |
| --- | --- | --- | --- |
| [🔗](#tab:fpos.operations-row-2) | | **semantics** | **pre-/post-condition** |
| [🔗](#tab:fpos.operations-row-3)<br>P(o) | P | converts from offset | *Effects*: Value-initializes the state object[.](#tab:fpos.operations-row-3-column-4-sentence-1) |
| [🔗](#tab:fpos.operations-row-4)<br>P p(o); P p = o; | | | *Effects*: Value-initializes the state object[.](#tab:fpos.operations-row-4-column-4-sentence-1)<br> *Postconditions*: p == P(o) is true[.](#tab:fpos.operations-row-4-column-4-sentence-2) |
| [🔗](#tab:fpos.operations-row-5)<br>P() | P | P(0) | |
| [🔗](#tab:fpos.operations-row-6)<br>P p; | | P p(0); | |
| [🔗](#tab:fpos.operations-row-7)<br>O(p) | streamoff | converts to offset | P(O(p)) == p |
| [🔗](#tab:fpos.operations-row-8)<br>p == q | bool | | *Remarks*: For any two values o and o2, if p is obtained from o converted to P or from a copy of such P value and if q is obtained from o2 converted to P or from a copy of such P value, then p == q is true only if o == o2 is true[.](#tab:fpos.operations-row-8-column-4-sentence-1) |
| [🔗](#tab:fpos.operations-row-9)<br>p != q | bool | !(p == q) | |
| [🔗](#tab:fpos.operations-row-10)<br>p + o | P | + offset | *Remarks*: With ql = p + o;, then: ql - o == p |
| [🔗](#tab:fpos.operations-row-11)<br>pl += o | P& | += offset | *Remarks*: With ql = pl; before the +=, then: pl - o == ql |
| [🔗](#tab:fpos.operations-row-12)<br>p - o | P | - offset | *Remarks*: With ql = p - o;, then: ql + o == p |
| [🔗](#tab:fpos.operations-row-13)<br>pl -= o | P& | -= offset | *Remarks*: With ql = pl; before the -=, then: pl + o == ql |
| [🔗](#tab:fpos.operations-row-14)<br>o + p | convertible to P | p + o | P(o + p) == p + o |
| [🔗](#tab:fpos.operations-row-15)<br>p - q | streamoff | distance | p == q + (p - q) |
[2](#fpos.operations-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L1790)
Stream operations that return a value of typetraits::pos_type returnP(O(-1)) as an invalid value to signal an error[.](#fpos.operations-2.sentence-1)
If this value is used as an argument to anyistream,ostream,
orstreambuf member
that accepts a value of typetraits::pos_type then the behavior of that function is undefined[.](#fpos.operations-2.sentence-2)
### [31.5.4](#ios) Class template basic_ios [[ios]](ios)
#### [31.5.4.1](#ios.overview) Overview [[ios.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.5.4.2](#basic.ios.cons) Constructors [[basic.ios.cons]](basic.ios.cons)
[🔗](#lib:basic_ios,constructor)
`explicit basic_ios(basic_streambuf<charT, traits>* sb);
`
[1](#basic.ios.cons-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L1879)
*Effects*: Assigns initial values to its member objects by callinginit(sb)[.](#basic.ios.cons-1.sentence-1)
[🔗](#lib:basic_ios,constructor_)
`basic_ios();
`
[2](#basic.ios.cons-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L1891)
*Effects*: Leaves its member objects uninitialized[.](#basic.ios.cons-2.sentence-1)
The object
shall be initialized by callingbasic_ios::init before its first use or before it is destroyed, whichever comes first; otherwise the
behavior is undefined[.](#basic.ios.cons-2.sentence-2)
[🔗](#lib:basic_ios,destructor)
`~basic_ios();
`
[3](#basic.ios.cons-3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L1906)
*Remarks*: The destructor does not destroyrdbuf()[.](#basic.ios.cons-3.sentence-1)
[🔗](#lib:init,basic_ios)
`void init(basic_streambuf<charT, traits>* sb);
`
[4](#basic.ios.cons-4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L1918)
*Postconditions*: The postconditions of this function are indicated in Table [142](#tab:basic.ios.cons "Table 142: basic_­ios::init() effects")[.](#basic.ios.cons-4.sentence-1)
Table [142](#tab:basic.ios.cons) — basic_ios::init() effects [[tab:basic.ios.cons]](./tab:basic.ios.cons)
| [🔗](#tab:basic.ios.cons-row-1)<br>**Element** | **Value** |
| --- | --- |
| [🔗](#tab:basic.ios.cons-row-2)<br>rdbuf() | sb |
| [🔗](#tab:basic.ios.cons-row-3)<br>tie() | 0 |
| [🔗](#tab:basic.ios.cons-row-4)<br>rdstate() | goodbit if sb is not a null pointer, otherwise badbit[.](#tab:basic.ios.cons-row-4-column-2-sentence-1) |
| [🔗](#tab:basic.ios.cons-row-5)<br>exceptions() | goodbit |
| [🔗](#tab:basic.ios.cons-row-6)<br>flags() | skipws | dec |
| [🔗](#tab:basic.ios.cons-row-7)<br>width() | 0 |
| [🔗](#tab:basic.ios.cons-row-8)<br>precision() | 6 |
| [🔗](#tab:basic.ios.cons-row-9)<br>fill() | widen(' ') |
| [🔗](#tab:basic.ios.cons-row-10)<br>getloc() | a copy of the value returned by locale() |
| [🔗](#tab:basic.ios.cons-row-11)<br>*iarray* | a null pointer |
| [🔗](#tab:basic.ios.cons-row-12)<br>*parray* | a null pointer |
#### [31.5.4.3](#basic.ios.members) Member functions [[basic.ios.members]](basic.ios.members)
[🔗](#lib:tie,basic_ios)
`basic_ostream<charT, traits>* tie() const;
`
[1](#basic.ios.members-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L1956)
*Returns*: An output sequence that is*tied* to (synchronized with) the sequence controlled by the stream buffer[.](#basic.ios.members-1.sentence-1)
[🔗](#lib:tie,basic_ios_)
`basic_ostream<charT, traits>* tie(basic_ostream<charT, traits>* tiestr);
`
[2](#basic.ios.members-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L1969)
*Preconditions*: If tiestr is not null, tiestr is not reachable by
traversing the linked list of tied stream objects starting fromtiestr->tie()[.](#basic.ios.members-2.sentence-1)
[3](#basic.ios.members-3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L1975)
*Postconditions*: tiestr == tie()[.](#basic.ios.members-3.sentence-1)
[4](#basic.ios.members-4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L1979)
*Returns*: The previous value oftie()[.](#basic.ios.members-4.sentence-1)
[🔗](#lib:rdbuf,basic_ios)
`basic_streambuf<charT, traits>* rdbuf() const;
`
[5](#basic.ios.members-5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L1991)
*Returns*: A pointer to thestreambuf associated with the stream[.](#basic.ios.members-5.sentence-1)
[🔗](#lib:rdbuf,basic_ios_)
`basic_streambuf<charT, traits>* rdbuf(basic_streambuf<charT, traits>* sb);
`
[6](#basic.ios.members-6)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L2004)
*Effects*: Callsclear()[.](#basic.ios.members-6.sentence-1)
[7](#basic.ios.members-7)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L2009)
*Postconditions*: sb == rdbuf()[.](#basic.ios.members-7.sentence-1)
[8](#basic.ios.members-8)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L2013)
*Returns*: The previous value ofrdbuf()[.](#basic.ios.members-8.sentence-1)
[🔗](#lib:imbue,basic_ios)
`locale imbue(const locale& loc);
`
[9](#basic.ios.members-9)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L2025)
*Effects*: Calls[ios_base::imbue](#lib:ios_base,imbue "31.5.2.4Functions[ios.base.locales]")(loc) and
ifrdbuf() != 0 thenrdbuf()->[pubimbue](streambuf.locales#lib:basic_streambuf,pubimbue "31.6.3.3.1Locales[streambuf.locales]")(loc)[.](#basic.ios.members-9.sentence-1)
[10](#basic.ios.members-10)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L2035)
*Returns*: The prior value ofios_base::imbue()[.](#basic.ios.members-10.sentence-1)
[🔗](#lib:narrow,basic_ios)
`char narrow(char_type c, char dfault) const;
`
[11](#basic.ios.members-11)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L2047)
*Returns*: use_facet<ctype<char_type>>(getloc()).narrow(c, dfault)[.](#basic.ios.members-11.sentence-1)
[🔗](#lib:widen,basic_ios)
`char_type widen(char c) const;
`
[12](#basic.ios.members-12)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L2058)
*Returns*: use_facet<ctype<char_type>>(getloc()).widen(c)[.](#basic.ios.members-12.sentence-1)
[🔗](#lib:fill,basic_ios)
`char_type fill() const;
`
[13](#basic.ios.members-13)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L2069)
*Returns*: The character used to pad (fill) an output conversion to the specified
field width[.](#basic.ios.members-13.sentence-1)
[🔗](#lib:fill,basic_ios_)
`char_type fill(char_type fillch);
`
[14](#basic.ios.members-14)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L2081)
*Postconditions*: traits::eq(fillch, fill())[.](#basic.ios.members-14.sentence-1)
[15](#basic.ios.members-15)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L2085)
*Returns*: The previous value offill()[.](#basic.ios.members-15.sentence-1)
[🔗](#lib:copyfmt,basic_ios)
`basic_ios& copyfmt(const basic_ios& rhs);
`
[16](#basic.ios.members-16)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L2097)
*Effects*: If(this == addressof(rhs)) is true does nothing[.](#basic.ios.members-16.sentence-1)
Otherwise assigns to the member objects of*this the corresponding member objects of rhs as follows:
- [(16.1)](#basic.ios.members-16.1)
calls each registered callback pair (fn, idx) as(*fn)(erase_event, *this, idx);
- [(16.2)](#basic.ios.members-16.2)
then, assigns to the member objects of *this the corresponding member objects ofrhs, except that
* [(16.2.1)](#basic.ios.members-16.2.1)
rdstate(), rdbuf(), and exceptions() are left unchanged;
* [(16.2.2)](#basic.ios.members-16.2.2)
the contents of arrays pointed at by pword and iword are copied,
not the pointers themselves;[263](#footnote-263 "This suggests an infinite amount of copying, but the implementation can keep track of the maximum element of the arrays that is nonzero.") and
* [(16.2.3)](#basic.ios.members-16.2.3)
if any newly stored pointer values in *this point at objects stored outside
the object rhs and those objects are destroyed when rhs is destroyed, the
newly stored pointer values are altered to point at newly constructed copies of the
objects;
- [(16.3)](#basic.ios.members-16.3)
then, calls each callback pair that was copied from rhs as(*fn)(copyfmt_event, *this, idx);
- [(16.4)](#basic.ios.members-16.4)
then, calls exceptions(rhs.exceptions())[.](#basic.ios.members-16.sentence-2)
[17](#basic.ios.members-17)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L2134)
[*Note [1](#basic.ios.members-note-1)*:
The second pass through the callback pairs permits a copied pword value to be zeroed, or to have its referent deep copied or reference counted, or to have
other special action taken[.](#basic.ios.members-17.sentence-1)
— *end note*]
[18](#basic.ios.members-18)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L2141)
*Postconditions*: The postconditions of this function are indicated in Table [143](#tab:basic.ios.copyfmt "Table 143: basic_­ios::copyfmt() effects")[.](#basic.ios.members-18.sentence-1)
Table [143](#tab:basic.ios.copyfmt) — basic_ios::copyfmt() effects [[tab:basic.ios.copyfmt]](./tab:basic.ios.copyfmt)
| [🔗](#tab:basic.ios.copyfmt-row-1)<br>**Element** | **Value** |
| --- | --- |
| [🔗](#tab:basic.ios.copyfmt-row-2)<br>rdbuf() | *unchanged* |
| [🔗](#tab:basic.ios.copyfmt-row-3)<br>tie() | rhs.tie() |
| [🔗](#tab:basic.ios.copyfmt-row-4)<br>rdstate() | *unchanged* |
| [🔗](#tab:basic.ios.copyfmt-row-5)<br>exceptions() | rhs.exceptions() |
| [🔗](#tab:basic.ios.copyfmt-row-6)<br>flags() | rhs.flags() |
| [🔗](#tab:basic.ios.copyfmt-row-7)<br>width() | rhs.width() |
| [🔗](#tab:basic.ios.copyfmt-row-8)<br>precision() | rhs.precision() |
| [🔗](#tab:basic.ios.copyfmt-row-9)<br>fill() | rhs.fill() |
| [🔗](#tab:basic.ios.copyfmt-row-10)<br>getloc() | rhs.getloc() |
[19](#basic.ios.members-19)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L2167)
*Returns*: *this[.](#basic.ios.members-19.sentence-1)
[🔗](#lib:move,basic_ios)
`void move(basic_ios& rhs);
void move(basic_ios&& rhs);
`
[20](#basic.ios.members-20)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L2179)
*Postconditions*: *this has the state thatrhs had before the function call, except thatrdbuf() returns nullptr[.](#basic.ios.members-20.sentence-1)
rhs is in a valid but
unspecified state, except that rhs.rdbuf() returns the
same value as it returned before the function call, andrhs.tie() returns nullptr[.](#basic.ios.members-20.sentence-2)
[🔗](#lib:swap,basic_ios)
`void swap(basic_ios& rhs) noexcept;
`
[21](#basic.ios.members-21)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L2195)
*Effects*: The states of *this and rhs are exchanged, except that rdbuf() returns the same
value as it returned before the function call, and rhs.rdbuf() returns the same value as it returned before the function call[.](#basic.ios.members-21.sentence-1)
[🔗](#lib:set_rdbuf,basic_ios)
`void set_rdbuf(basic_streambuf<charT, traits>* sb);
`
[22](#basic.ios.members-22)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L2209)
*Preconditions*: sb != nullptr is true[.](#basic.ios.members-22.sentence-1)
[23](#basic.ios.members-23)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L2213)
*Effects*: Associates the basic_streambuf object
pointed to by sb with this stream without callingclear()[.](#basic.ios.members-23.sentence-1)
[24](#basic.ios.members-24)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L2219)
*Postconditions*: rdbuf() == sb is true[.](#basic.ios.members-24.sentence-1)
[25](#basic.ios.members-25)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L2223)
*Throws*: Nothing[.](#basic.ios.members-25.sentence-1)
[263)](#footnote-263)[263)](#footnoteref-263)
This suggests an infinite amount of copying, but the implementation can keep
track of the maximum element of the arrays that is nonzero[.](#footnote-263.sentence-1)
#### [31.5.4.4](#iostate.flags) Flags functions [[iostate.flags]](iostate.flags)
[🔗](#lib:operator_bool,basic_ios)
`explicit operator bool() const;
`
[1](#iostate.flags-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L2236)
*Returns*: !fail()[.](#iostate.flags-1.sentence-1)
[🔗](#lib:operator!,basic_ios)
`bool operator!() const;
`
[2](#iostate.flags-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L2247)
*Returns*: fail()[.](#iostate.flags-2.sentence-1)
[🔗](#lib:rdstate,basic_ios)
`iostate rdstate() const;
`
[3](#iostate.flags-3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L2258)
*Returns*: The error state of the stream buffer[.](#iostate.flags-3.sentence-1)
[🔗](#lib:clear,basic_ios)
`void clear(iostate state = goodbit);
`
[4](#iostate.flags-4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L2269)
*Effects*: If ((state | (rdbuf() ? goodbit : badbit)) & exceptions()) == 0,
returns[.](#iostate.flags-4.sentence-1)
Otherwise, the function throws an object of classios_base::failure ([[ios.failure]](#ios.failure "31.5.2.2.1Class ios_­base::failure")),
constructed withimplementation-defined
argument values[.](#iostate.flags-4.sentence-2)
[5](#iostate.flags-5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L2279)
*Postconditions*: Ifrdbuf() != 0 thenstate == rdstate();
otherwiserdstate() == (state | ios_base::badbit)[.](#iostate.flags-5.sentence-1)
[🔗](#lib:setstate,basic_ios)
`void setstate(iostate state);
`
[6](#iostate.flags-6)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L2295)
*Effects*: Callsclear(rdstate() | state) (which may throwios_base::failure ([[ios.failure]](#ios.failure "31.5.2.2.1Class ios_­base::failure")))[.](#iostate.flags-6.sentence-1)
[🔗](#lib:good,basic_ios)
`bool good() const;
`
[7](#iostate.flags-7)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L2309)
*Returns*: rdstate() == 0[.](#iostate.flags-7.sentence-1)
[🔗](#lib:eof,basic_ios)
`bool eof() const;
`
[8](#iostate.flags-8)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L2320)
*Returns*: true ifeofbit is set inrdstate()[.](#iostate.flags-8.sentence-1)
[🔗](#lib:fail,basic_ios)
`bool fail() const;
`
[9](#iostate.flags-9)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L2335)
*Returns*: true iffailbit orbadbit is set inrdstate()[.](#iostate.flags-9.sentence-1)[264](#footnote-264 "Checking badbit also for fail() is historical practice.")
[🔗](#lib:bad,basic_ios)
`bool bad() const;
`
[10](#iostate.flags-10)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L2359)
*Returns*: true ifbadbit is set inrdstate()[.](#iostate.flags-10.sentence-1)
[🔗](#lib:exceptions,basic_ios)
`iostate exceptions() const;
`
[11](#iostate.flags-11)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L2374)
*Returns*: A mask that determines what elements set inrdstate() cause exceptions to be thrown[.](#iostate.flags-11.sentence-1)
[🔗](#lib:exceptions,basic_ios_)
`void exceptions(iostate except);
`
[12](#iostate.flags-12)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L2387)
*Effects*: Callsclear(rdstate())[.](#iostate.flags-12.sentence-1)
[13](#iostate.flags-13)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L2392)
*Postconditions*: except == exceptions()[.](#iostate.flags-13.sentence-1)
[264)](#footnote-264)[264)](#footnoteref-264)
Checkingbadbit also forfail() is historical practice[.](#footnote-264.sentence-1)
### [31.5.5](#std.ios.manip) ios_base manipulators [[std.ios.manip]](std.ios.manip)
#### [31.5.5.1](#fmtflags.manip) fmtflags manipulators [[fmtflags.manip]](fmtflags.manip)
[1](#fmtflags.manip-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L2401)
Each function specified in this subclause
is a designated addressable function ([[namespace.std]](namespace.std "16.4.5.2.1Namespace std"))[.](#fmtflags.manip-1.sentence-1)
[🔗](#lib:boolalpha)
`ios_base& boolalpha(ios_base& str);
`
[2](#fmtflags.manip-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L2411)
*Effects*: Callsstr.setf(ios_base::boolalpha)[.](#fmtflags.manip-2.sentence-1)
[3](#fmtflags.manip-3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L2416)
*Returns*: str[.](#fmtflags.manip-3.sentence-1)
[🔗](#lib:noboolalpha)
`ios_base& noboolalpha(ios_base& str);
`
[4](#fmtflags.manip-4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L2427)
*Effects*: Callsstr.unsetf(ios_base::boolalpha)[.](#fmtflags.manip-4.sentence-1)
[5](#fmtflags.manip-5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L2432)
*Returns*: str[.](#fmtflags.manip-5.sentence-1)
[🔗](#lib:showbase)
`ios_base& showbase(ios_base& str);
`
[6](#fmtflags.manip-6)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L2443)
*Effects*: Callsstr.setf(ios_base::showbase)[.](#fmtflags.manip-6.sentence-1)
[7](#fmtflags.manip-7)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L2448)
*Returns*: str[.](#fmtflags.manip-7.sentence-1)
[🔗](#lib:noshowbase)
`ios_base& noshowbase(ios_base& str);
`
[8](#fmtflags.manip-8)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L2459)
*Effects*: Callsstr.unsetf(ios_base::showbase)[.](#fmtflags.manip-8.sentence-1)
[9](#fmtflags.manip-9)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L2464)
*Returns*: str[.](#fmtflags.manip-9.sentence-1)
[🔗](#lib:showpoint)
`ios_base& showpoint(ios_base& str);
`
[10](#fmtflags.manip-10)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L2475)
*Effects*: Callsstr.setf(ios_base::showpoint)[.](#fmtflags.manip-10.sentence-1)
[11](#fmtflags.manip-11)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L2480)
*Returns*: str[.](#fmtflags.manip-11.sentence-1)
[🔗](#lib:noshowpoint)
`ios_base& noshowpoint(ios_base& str);
`
[12](#fmtflags.manip-12)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L2491)
*Effects*: Callsstr.unsetf(ios_base::showpoint)[.](#fmtflags.manip-12.sentence-1)
[13](#fmtflags.manip-13)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L2496)
*Returns*: str[.](#fmtflags.manip-13.sentence-1)
[🔗](#lib:showpos)
`ios_base& showpos(ios_base& str);
`
[14](#fmtflags.manip-14)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L2507)
*Effects*: Callsstr.setf(ios_base::showpos)[.](#fmtflags.manip-14.sentence-1)
[15](#fmtflags.manip-15)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L2512)
*Returns*: str[.](#fmtflags.manip-15.sentence-1)
[🔗](#lib:noshowpos)
`ios_base& noshowpos(ios_base& str);
`
[16](#fmtflags.manip-16)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L2523)
*Effects*: Callsstr.unsetf(ios_base::showpos)[.](#fmtflags.manip-16.sentence-1)
[17](#fmtflags.manip-17)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L2528)
*Returns*: str[.](#fmtflags.manip-17.sentence-1)
[🔗](#lib:skipws)
`ios_base& skipws(ios_base& str);
`
[18](#fmtflags.manip-18)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L2539)
*Effects*: Callsstr.setf(ios_base::skipws)[.](#fmtflags.manip-18.sentence-1)
[19](#fmtflags.manip-19)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L2544)
*Returns*: str[.](#fmtflags.manip-19.sentence-1)
[🔗](#lib:noskipws)
`ios_base& noskipws(ios_base& str);
`
[20](#fmtflags.manip-20)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L2555)
*Effects*: Callsstr.unsetf(ios_base::skipws)[.](#fmtflags.manip-20.sentence-1)
[21](#fmtflags.manip-21)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L2560)
*Returns*: str[.](#fmtflags.manip-21.sentence-1)
[🔗](#lib:uppercase)
`ios_base& uppercase(ios_base& str);
`
[22](#fmtflags.manip-22)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L2571)
*Effects*: Callsstr.setf(ios_base::uppercase)[.](#fmtflags.manip-22.sentence-1)
[23](#fmtflags.manip-23)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L2576)
*Returns*: str[.](#fmtflags.manip-23.sentence-1)
[🔗](#lib:nouppercase)
`ios_base& nouppercase(ios_base& str);
`
[24](#fmtflags.manip-24)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L2587)
*Effects*: Callsstr.unsetf(ios_base::uppercase)[.](#fmtflags.manip-24.sentence-1)
[25](#fmtflags.manip-25)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L2592)
*Returns*: str[.](#fmtflags.manip-25.sentence-1)
[🔗](#lib:unitbuf)
`ios_base& unitbuf(ios_base& str);
`
[26](#fmtflags.manip-26)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L2603)
*Effects*: Callsstr.setf(ios_base::unitbuf)[.](#fmtflags.manip-26.sentence-1)
[27](#fmtflags.manip-27)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L2608)
*Returns*: str[.](#fmtflags.manip-27.sentence-1)
[🔗](#lib:nounitbuf)
`ios_base& nounitbuf(ios_base& str);
`
[28](#fmtflags.manip-28)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L2619)
*Effects*: Callsstr.unsetf(ios_base::unitbuf)[.](#fmtflags.manip-28.sentence-1)
[29](#fmtflags.manip-29)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L2624)
*Returns*: str[.](#fmtflags.manip-29.sentence-1)
#### [31.5.5.2](#adjustfield.manip) adjustfield manipulators [[adjustfield.manip]](adjustfield.manip)
[1](#adjustfield.manip-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L2631)
Each function specified in this subclause
is a designated addressable function ([[namespace.std]](namespace.std "16.4.5.2.1Namespace std"))[.](#adjustfield.manip-1.sentence-1)
[🔗](#lib:internal)
`ios_base& internal(ios_base& str);
`
[2](#adjustfield.manip-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L2641)
*Effects*: Callsstr.setf(ios_base::internal, ios_base::adjustfield)[.](#adjustfield.manip-2.sentence-1)
[3](#adjustfield.manip-3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L2646)
*Returns*: str[.](#adjustfield.manip-3.sentence-1)
[🔗](#lib:left)
`ios_base& left(ios_base& str);
`
[4](#adjustfield.manip-4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L2657)
*Effects*: Callsstr.setf(ios_base::left, ios_base::adjustfield)[.](#adjustfield.manip-4.sentence-1)
[5](#adjustfield.manip-5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L2662)
*Returns*: str[.](#adjustfield.manip-5.sentence-1)
[🔗](#lib:right)
`ios_base& right(ios_base& str);
`
[6](#adjustfield.manip-6)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L2673)
*Effects*: Callsstr.setf(ios_base::right, ios_base::adjustfield)[.](#adjustfield.manip-6.sentence-1)
[7](#adjustfield.manip-7)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L2678)
*Returns*: str[.](#adjustfield.manip-7.sentence-1)
#### [31.5.5.3](#basefield.manip) basefield manipulators [[basefield.manip]](basefield.manip)
[1](#basefield.manip-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L2685)
Each function specified in this subclause
is a designated addressable function ([[namespace.std]](namespace.std "16.4.5.2.1Namespace std"))[.](#basefield.manip-1.sentence-1)
[🔗](#lib:dec)
`ios_base& dec(ios_base& str);
`
[2](#basefield.manip-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L2695)
*Effects*: Callsstr.setf(ios_base::dec, ios_base::basefield)[.](#basefield.manip-2.sentence-1)
[3](#basefield.manip-3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L2700)
*Returns*: str[.](#basefield.manip-3.sentence-1)[265](#footnote-265 "The function signature dec(ios_­base&amp;) can be called by the function signature basic_­ostream&amp; stream::operator&lt;&lt;(ios_­base&amp; (*)(ios_­base&amp;)) to permit expressions of the form cout &lt;&lt; dec to change the format flags stored in cout.")
[🔗](#lib:hex)
`ios_base& hex(ios_base& str);
`
[4](#basefield.manip-4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L2722)
*Effects*: Callsstr.setf(ios_base::hex, ios_base::basefield)[.](#basefield.manip-4.sentence-1)
[5](#basefield.manip-5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L2727)
*Returns*: str[.](#basefield.manip-5.sentence-1)
[🔗](#lib:oct)
`ios_base& oct(ios_base& str);
`
[6](#basefield.manip-6)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L2738)
*Effects*: Callsstr.setf(ios_base::oct, ios_base::basefield)[.](#basefield.manip-6.sentence-1)
[7](#basefield.manip-7)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L2743)
*Returns*: str[.](#basefield.manip-7.sentence-1)
[265)](#footnote-265)[265)](#footnoteref-265)
The function signaturedec(ios_base&) can be called by
the function signaturebasic_ostream& stream::operator<<(ios_base& (*)(ios_base&)) to permit expressions of the formcout << dec to change the format flags stored incout[.](#footnote-265.sentence-1)
#### [31.5.5.4](#floatfield.manip) floatfield manipulators [[floatfield.manip]](floatfield.manip)
[1](#floatfield.manip-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L2750)
Each function specified in this subclause
is a designated addressable function ([[namespace.std]](namespace.std "16.4.5.2.1Namespace std"))[.](#floatfield.manip-1.sentence-1)
[🔗](#lib:fixed)
`ios_base& fixed(ios_base& str);
`
[2](#floatfield.manip-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L2760)
*Effects*: Callsstr.setf(ios_base::fixed, ios_base::floatfield)[.](#floatfield.manip-2.sentence-1)
[3](#floatfield.manip-3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L2765)
*Returns*: str[.](#floatfield.manip-3.sentence-1)
[🔗](#lib:scientific)
`ios_base& scientific(ios_base& str);
`
[4](#floatfield.manip-4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L2776)
*Effects*: Callsstr.setf(ios_base::scientific, ios_base::floatfield)[.](#floatfield.manip-4.sentence-1)
[5](#floatfield.manip-5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L2781)
*Returns*: str[.](#floatfield.manip-5.sentence-1)
[🔗](#lib:hexfloat)
`ios_base& hexfloat(ios_base& str);
`
[6](#floatfield.manip-6)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L2792)
*Effects*: Calls str.setf(ios_base::fixed | ios_base::scientific,
ios_base::floatfield)[.](#floatfield.manip-6.sentence-1)
[7](#floatfield.manip-7)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L2797)
*Returns*: str[.](#floatfield.manip-7.sentence-1)
[8](#floatfield.manip-8)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L2802)
[*Note [1](#floatfield.manip-note-1)*:
ios_base::hex cannot be used to specify
a hexadecimal floating-point format,
because it is not part of ios_base::floatfield (Table [137](#tab:ios.fmtflags.const "Table 137: fmtflags constants"))[.](#floatfield.manip-8.sentence-1)
— *end note*]
[🔗](#lib:defaultfloat)
`ios_base& defaultfloat(ios_base& str);
`
[9](#floatfield.manip-9)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L2816)
*Effects*: Calls str.unsetf(ios_base::floatfield)[.](#floatfield.manip-9.sentence-1)
[10](#floatfield.manip-10)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L2820)
*Returns*: str[.](#floatfield.manip-10.sentence-1)
### [31.5.6](#error.reporting) Error reporting [[error.reporting]](error.reporting)
[🔗](#lib:make_error_code,io_errc)
`error_code make_error_code(io_errc e) noexcept;
`
[1](#error.reporting-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L2833)
*Returns*: error_code(static_cast<int>(e), iostream_category())[.](#error.reporting-1.sentence-1)
[🔗](#lib:make_error_condition,io_errc)
`error_condition make_error_condition(io_errc e) noexcept;
`
[2](#error.reporting-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L2844)
*Returns*: error_condition(static_cast<int>(e), iostream_category())[.](#error.reporting-2.sentence-1)
[🔗](#lib:iostream_category)
`const error_category& iostream_category() noexcept;
`
[3](#error.reporting-3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L2855)
*Returns*: A reference to an object of a type derived from classerror_category[.](#error.reporting-3.sentence-1)
[4](#error.reporting-4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L2860)
The object's default_error_condition and equivalent virtual functions shall behave as specified for the class error_category[.](#error.reporting-4.sentence-1)
The object's name virtual function shall return a pointer to the string "iostream"[.](#error.reporting-4.sentence-2)