#include <iosfwd> // see [iosfwd.syn] namespace std { using streamoff = implementation-defined; using streamsize = implementation-defined; template <class stateT> class fpos; class ios_base; template <class charT, class traits = char_traits<charT>> class basic_ios; // [std.ios.manip], 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 ios_base& internal (ios_base& str); ios_base& left (ios_base& str); ios_base& right (ios_base& str); // [basefield.manip], basefield ios_base& dec (ios_base& str); ios_base& hex (ios_base& str); ios_base& oct (ios_base& str); // [floatfield.manip], 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 enum class io_errc { stream = 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; }
using streamoff = implementation-defined;
using streamsize = implementation-defined;
namespace std { class ios_base { public: class failure; // see below // [ios::fmtflags], fmtflags using 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], iostate using 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], openmode using 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 out = unspecified; static constexpr openmode trunc = unspecified; // [ios::seekdir], seekdir using seekdir = T4; static constexpr seekdir beg = unspecified; static constexpr seekdir cur = unspecified; static constexpr seekdir end = unspecified; class Init; // [fmtflags.state], 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 locale imbue(const locale& loc); locale getloc() const; // [ios.base.storage], storage static int xalloc(); long& iword(int index); void*& pword(int index); // destructor: virtual ~ios_base(); // [ios.base.callback], callbacks; enum event { erase_event, imbue_event, copyfmt_event }; using event_callback = void (*)(event, ios_base&, int index); void register_callback(event_callback fn, int index); 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 }; }
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); }; }
explicit failure(const string& msg, const error_code& ec = io_errc::stream);
explicit failure(const char* msg, const error_code& ec = io_errc::stream);
using fmtflags = T1;
Element | Effect(s) if set |
boolalpha | insert and extract bool type in alphabetic format |
dec | converts integer input or generates integer output in decimal base |
fixed | generate floating-point output in fixed-point notation |
hex | converts integer input or generates integer output in hexadecimal base |
internal | adds fill characters at a designated internal point in certain generated output,
or identical to right if no such point is designated |
left | adds fill characters on the right (final positions) of certain generated output |
oct | converts integer input or generates integer output in octal base |
right | adds fill characters on the left (initial positions) of certain generated output |
scientific | generates floating-point output in scientific notation |
showbase | generates a prefix indicating the numeric base of generated integer output |
showpoint | generates a decimal-point character unconditionally in generated floating-point output |
showpos | generates a + sign in non-negative generated numeric output |
skipws | skips leading whitespace before certain input operations |
unitbuf | flushes output after each output operation |
uppercase | replaces certain lowercase letters with their uppercase equivalents in generated output |
using iostate = T2;
Element | Effect(s) if set |
badbit | indicates a loss of integrity in an input or output sequence
(such as an irrecoverable read error from a file); |
eofbit | indicates that an input operation reached the end of an input sequence; |
failbit | indicates that an input operation failed to read the expected characters,
or that an output operation failed to generate the desired characters. |
using openmode = T3;
Element | Effect(s) if set |
app | seek to end before each write |
ate | open and seek to end immediately after opening |
binary | perform input and output in binary mode (as opposed to text mode) |
in | open for input |
out | open for output |
trunc | truncate an existing stream when opening |
using seekdir = T4;
Element | Meaning |
beg | request a seek (for subsequent input or output) relative to the beginning of the stream |
cur | request a seek relative to the current position within the sequence |
end | request a seek relative to the current end of the sequence |
namespace std {
class ios_base::Init {
public:
Init();
~Init();
private:
static int init_cnt; // exposition only
};
}
Init();
~Init();
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);
locale imbue(const locale& loc);
locale getloc() const;
bool sync_with_stdio(bool sync = true);
fputc(f, c);is the same as the effect of
str.rdbuf()->sputc(c);for any sequences of characters; the effect of extracting a character c by
c = fgetc(f);is the same as the effect of
c = str.rdbuf()->sbumpc();for any sequences of characters; and the effect of pushing back a character c by
ungetc(c, f);is the same as the effect of
str.rdbuf()->sputbackc(c);for any sequence of characters.292
static int xalloc();
long& iword(int idx);
void*& pword(int idx);
void register_callback(event_callback fn, int index);
ios_base();
~ios_base();
namespace std { template <class stateT> class fpos { public: // [fpos.members], members stateT state() const; void state(stateT); private; stateT st; // exposition only }; }
Expression | Return type | Operational | Assertion/note |
semantics | pre-/post-condition | ||
P(i) | |||
P p(i); P p = i; | |||
P(o) | fpos | converts from offset | |
O(p) | streamoff | converts to offset | P(O(p)) == p |
p == q | convertible to bool | == is an equivalence relation | |
p != q | convertible to bool | !(p == q) | |
q = p + o p += o | fpos | + offset | q - o == p |
q = p - o p -= o | fpos | - offset | q + o == p |
o = p - q | streamoff | distance | q + o == p |
streamsize(o) O(sz) | streamsize streamoff | converts converts | streamsize(O(sz)) == sz streamsize(O(sz)) == sz |
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], flags functions explicit 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], constructor/destructor explicit basic_ios(basic_streambuf<charT, traits>* sb); virtual ~basic_ios(); // [basic.ios.members], 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); }; }
explicit basic_ios(basic_streambuf<charT, traits>* sb);
basic_ios();
~basic_ios();
void init(basic_streambuf<charT, traits>* sb);
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);
locale imbue(const locale& loc);
char narrow(char_type c, char dfault) const;
char_type widen(char c) const;
char_type fill() const;
char_type fill(char_type fillch);
basic_ios& copyfmt(const basic_ios& rhs);
Element | Value |
rdbuf() | unchanged |
tie() | rhs.tie() |
rdstate() | unchanged |
exceptions() | rhs.exceptions() |
flags() | rhs.flags() |
width() | rhs.width() |
precision() | rhs.precision() |
fill() | rhs.fill() |
getloc() | rhs.getloc() |
void move(basic_ios& rhs);
void move(basic_ios&& rhs);
void swap(basic_ios& rhs) noexcept;
void set_rdbuf(basic_streambuf<charT, traits>* sb);
explicit 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);
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);
ios_base& internal(ios_base& str);
ios_base& left(ios_base& str);
ios_base& right(ios_base& str);
ios_base& dec(ios_base& str);
ios_base& hex(ios_base& str);
ios_base& oct(ios_base& str);
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_code make_error_code(io_errc e) noexcept;
error_condition make_error_condition(io_errc e) noexcept;
const error_category& iostream_category() noexcept;