Subclause | Header | ||
Requirements | |||
Forward declarations | <iosfwd> | ||
Standard iostream objects | <iostream> | ||
Iostreams base classes | <ios> | ||
Stream buffers | <streambuf> | ||
Formatting and manipulators | <iomanip>, <istream>, <ostream> | ||
String streams | <sstream> | ||
File streams | <fstream> | ||
Synchronized output streams | <syncstream> | ||
File systems | <filesystem> | ||
C library files | <cstdio>, <cinttypes> |
istream cin;
ostream cout;
ostream cerr;
ostream clog;
wistream wcin;
wostream wcout;
wostream wcerr;
wostream wclog;
using streamoff = implementation-defined;
using streamsize = implementation-defined;
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;
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;
static bool sync_with_stdio(bool sync = true);
static int xalloc();
long& iword(int idx);
void*& pword(int idx);
void register_callback(event_callback fn, int idx);
ios_base();
~ios_base();
Expression | Return type | Operational | Assertion/note | |
semantics | pre-/post-condition | |||
P(o) | P | converts from offset | Effects: Value-initializes the state object. | |
P p(o); P p = o; | Effects: Value-initializes the state object. Postconditions: p == P(o) | |||
P() | P | P(0) | ||
P p; | P p(0); | |||
O(p) | streamoff | converts to offset | P(O(p)) == p | |
p != q | convertible to bool | !(p == q) | ||
p + o | P | + offset | Remarks: With ql = p + o;, then: ql - o == p | |
pl += o | P& | += offset | Remarks: With ql = pl; before the +=, then:
pl - o == ql | |
p - o | P | - offset | Remarks: With ql = p - o;, then: ql + o == p | |
pl -= o | P& | -= offset | Remarks: With ql = pl; before the -=, then:
pl + o == ql | |
o + p | convertible to P | p + o | P(o + p) == p + o | |
p - q | streamoff | distance | p == q + (p - q) |
explicit basic_ios(basic_streambuf<charT, traits>* sb);
basic_ios();
~basic_ios();
void init(basic_streambuf<charT, traits>* sb);
Element | Value | |
rdbuf() | sb | |
tie() | 0 | |
rdstate() | ||
exceptions() | goodbit | |
flags() | skipws | dec | |
width() | 0 | |
precision() | 6 | |
fill() | widen(' ') | |
getloc() | a copy of the value returned by locale() | |
iarray | a null pointer | |
parray | a null pointer |
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);
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;
basic_streambuf();
basic_streambuf(const basic_streambuf& rhs);
~basic_streambuf();
locale pubimbue(const locale& loc);
locale getloc() const;
basic_streambuf* pubsetbuf(char_type* s, streamsize n);
pos_type pubseekoff(off_type off, ios_base::seekdir way,
ios_base::openmode which
= ios_base::in | ios_base::out);
pos_type pubseekpos(pos_type sp,
ios_base::openmode which
= ios_base::in | ios_base::out);
int pubsync();
streamsize in_avail();
int_type snextc();
int_type sbumpc();
int_type sgetc();
streamsize sgetn(char_type* s, streamsize n);
int_type sputc(char_type c);
streamsize sputn(const char_type* s, streamsize n);
basic_streambuf& operator=(const basic_streambuf& rhs);
void swap(basic_streambuf& rhs);
char_type* eback() const;
char_type* gptr() const;
char_type* egptr() const;
void gbump(int n);
void setg(char_type* gbeg, char_type* gnext, char_type* gend);
char_type* pbase() const;
char_type* pptr() const;
char_type* epptr() const;
void pbump(int n);
void setp(char_type* pbeg, char_type* pend);
basic_streambuf* setbuf(char_type* s, streamsize n);
pos_type seekoff(off_type off, ios_base::seekdir way,
ios_base::openmode which
= ios_base::in | ios_base::out);
pos_type seekpos(pos_type sp,
ios_base::openmode which
= ios_base::in | ios_base::out);
int sync();
streamsize xsgetn(char_type* s, streamsize n);
int_type underflow();
int_type uflow();
int_type pbackfail(int_type c = traits::eof());
streamsize xsputn(const char_type* s, streamsize n);
int_type overflow(int_type c = traits::eof());
explicit basic_istream(basic_streambuf<charT, traits>* sb);
basic_istream(basic_istream&& rhs);
virtual ~basic_istream();
basic_istream& operator=(basic_istream&& rhs);
void swap(basic_istream& rhs);
explicit sentry(basic_istream<charT, traits>& is, bool noskipws = false);
~sentry();
explicit operator bool() const;
operator>>(unsigned short& val);
operator>>(unsigned int& val);
operator>>(long& val);
operator>>(unsigned long& val);
operator>>(long long& val);
operator>>(unsigned long long& val);
operator>>(float& val);
operator>>(double& val);
operator>>(long double& val);
operator>>(bool& val);
operator>>(void*& val);
operator>>(short& val);
operator>>(int& val);
basic_istream<charT, traits>&
operator>>(basic_istream<charT, traits>& (*pf)(basic_istream<charT, traits>&));
basic_istream<charT, traits>&
operator>>(basic_ios<charT, traits>& (*pf)(basic_ios<charT, traits>&));
basic_istream<charT, traits>& operator>>(ios_base& (*pf)(ios_base&));
template<class charT, class traits, size_t N>
basic_istream<charT, traits>& operator>>(basic_istream<charT, traits>& in, charT (&s)[N]);
template<class traits, size_t N>
basic_istream<char, traits>& operator>>(basic_istream<char, traits>& in, unsigned char (&s)[N]);
template<class traits, size_t N>
basic_istream<char, traits>& operator>>(basic_istream<char, traits>& in, signed char (&s)[N]);
template<class charT, class traits>
basic_istream<charT, traits>& operator>>(basic_istream<charT, traits>& in, charT& c);
template<class traits>
basic_istream<char, traits>& operator>>(basic_istream<char, traits>& in, unsigned char& c);
template<class traits>
basic_istream<char, traits>& operator>>(basic_istream<char, traits>& in, signed char& c);
basic_istream<charT, traits>& operator>>(basic_streambuf<charT, traits>* sb);
streamsize gcount() const;
int_type get();
basic_istream<charT, traits>& get(char_type& c);
basic_istream<charT, traits>& get(char_type* s, streamsize n, char_type delim);
basic_istream<charT, traits>& get(char_type* s, streamsize n);
basic_istream<charT, traits>& get(basic_streambuf<char_type, traits>& sb, char_type delim);
basic_istream<charT, traits>& get(basic_streambuf<char_type, traits>& sb);
basic_istream<charT, traits>& getline(char_type* s, streamsize n, char_type delim);
1. | end-of-file occurs on the input sequence (in which case the function calls setstate(eofbit)); |
2. | traits::eq(c, delim) for the next available input character c (in which case the input character is extracted but not stored);313 |
3. | n is less than one or n - 1 characters are stored (in which case the function calls setstate(failbit)). |
basic_istream<charT, traits>& getline(char_type* s, streamsize n);
basic_istream<charT, traits>& ignore(streamsize n = 1, int_type delim = traits::eof());
int_type peek();
basic_istream<charT, traits>& read(char_type* s, streamsize n);
streamsize readsome(char_type* s, streamsize n);
basic_istream<charT, traits>& putback(char_type c);
basic_istream<charT, traits>& unget();
int sync();
pos_type tellg();
basic_istream<charT, traits>& seekg(pos_type pos);
basic_istream<charT, traits>& seekg(off_type off, ios_base::seekdir dir);
template<class charT, class traits>
basic_istream<charT, traits>& ws(basic_istream<charT, traits>& is);
template<class Istream, class T>
Istream&& operator>>(Istream&& is, T&& x);
explicit basic_iostream(basic_streambuf<charT, traits>* sb);
basic_iostream(basic_iostream&& rhs);
virtual ~basic_iostream();
basic_iostream& operator=(basic_iostream&& rhs);
void swap(basic_iostream& rhs);
explicit basic_ostream(basic_streambuf<charT, traits>* sb);
basic_ostream(basic_ostream&& rhs);
virtual ~basic_ostream();
basic_ostream& operator=(basic_ostream&& rhs);
void swap(basic_ostream& rhs);
explicit sentry(basic_ostream<charT, traits>& os);
~sentry();
explicit operator bool() const;
pos_type tellp();
basic_ostream<charT, traits>& seekp(pos_type pos);
basic_ostream<charT, traits>& seekp(off_type off, ios_base::seekdir dir);
operator<<(bool val);
operator<<(short val);
operator<<(unsigned short val);
operator<<(int val);
operator<<(unsigned int val);
operator<<(long val);
operator<<(unsigned long val);
operator<<(long long val);
operator<<(unsigned long long val);
operator<<(float val);
operator<<(double val);
operator<<(long double val);
operator<<(const void* val);
basic_ostream<charT, traits>&
operator<<(basic_ostream<charT, traits>& (*pf)(basic_ostream<charT, traits>&));
basic_ostream<charT, traits>&
operator<<(basic_ios<charT, traits>& (*pf)(basic_ios<charT, traits>&));
basic_ostream<charT, traits>& operator<<(ios_base& (*pf)(ios_base&));
basic_ostream<charT, traits>& operator<<(basic_streambuf<charT, traits>* sb);
basic_ostream<charT, traits>& operator<<(nullptr_t);
template<class charT, class traits>
basic_ostream<charT, traits>& operator<<(basic_ostream<charT, traits>& out, charT c);
template<class charT, class traits>
basic_ostream<charT, traits>& operator<<(basic_ostream<charT, traits>& out, char c);
// specialization
template<class traits>
basic_ostream<char, traits>& operator<<(basic_ostream<char, traits>& out, char c);
// signed and unsigned
template<class traits>
basic_ostream<char, traits>& operator<<(basic_ostream<char, traits>& out, signed char c);
template<class traits>
basic_ostream<char, traits>& operator<<(basic_ostream<char, traits>& out, unsigned char c);
template<class charT, class traits>
basic_ostream<charT, traits>& operator<<(basic_ostream<charT, traits>& out, const charT* s);
template<class charT, class traits>
basic_ostream<charT, traits>& operator<<(basic_ostream<charT, traits>& out, const char* s);
template<class traits>
basic_ostream<char, traits>& operator<<(basic_ostream<char, traits>& out, const char* s);
template<class traits>
basic_ostream<char, traits>& operator<<(basic_ostream<char, traits>& out, const signed char* s);
template<class traits>
basic_ostream<char, traits>& operator<<(basic_ostream<char, traits>& out,
const unsigned char* s);
basic_ostream<charT, traits>& put(char_type c);
basic_ostream& write(const char_type* s, streamsize n);
basic_ostream& flush();
template<class charT, class traits>
basic_ostream<charT, traits>& endl(basic_ostream<charT, traits>& os);
template<class charT, class traits>
basic_ostream<charT, traits>& ends(basic_ostream<charT, traits>& os);
template<class charT, class traits>
basic_ostream<charT, traits>& flush(basic_ostream<charT, traits>& os);
template<class charT, class traits>
basic_ostream<charT, traits>& emit_on_flush(basic_ostream<charT, traits>& os);
template<class charT, class traits>
basic_ostream<charT, traits>& noemit_on_flush(basic_ostream<charT, traits>& os);
template<class charT, class traits>
basic_ostream<charT, traits>& flush_emit(basic_ostream<charT, traits>& os);
template<class Ostream, class T>
Ostream&& operator<<(Ostream&& os, const T& x);
unspecified resetiosflags(ios_base::fmtflags mask);
unspecified setiosflags(ios_base::fmtflags mask);
unspecified setbase(int base);
unspecified setfill(char_type c);
unspecified setprecision(int n);
unspecified setw(int n);
template<class moneyT> unspecified get_money(moneyT& mon, bool intl = false);
template<class moneyT> unspecified put_money(const moneyT& mon, bool intl = false);
template<class charT> unspecified get_time(struct tm* tmb, const charT* fmt);
template<class charT> unspecified put_time(const struct tm* tmb, const charT* fmt);
template<class charT>
unspecified quoted(const charT* s, charT delim = charT('"'), charT escape = charT('\\'));
template<class charT, class traits, class Allocator>
unspecified quoted(const basic_string<charT, traits, Allocator>& s,
charT delim = charT('"'), charT escape = charT('\\'));
template<class charT, class traits>
unspecified quoted(basic_string_view<charT, traits> s,
charT delim = charT('"'), charT escape = charT('\\'));
template<class charT, class traits, class Allocator>
unspecified quoted(basic_string<charT, traits, Allocator>& s,
charT delim = charT('"'), charT escape = charT('\\'));
explicit basic_stringbuf(ios_base::openmode which);
explicit basic_stringbuf(
const basic_string<charT, traits, Allocator>& s,
ios_base::openmode which = ios_base::in | ios_base::out);
basic_stringbuf(ios_base::openmode which, const Allocator &a);
explicit basic_stringbuf(
basic_string<charT, traits, Allocator>&& s,
ios_base::openmode which = ios_base::in | ios_base::out);
template<class SAlloc>
basic_stringbuf(
const basic_string<charT, traits, SAlloc>& s,
ios_base::openmode which, const Allocator &a);
template<class SAlloc>
explicit basic_stringbuf(
const basic_string<charT, traits, SAlloc>& s,
ios_base::openmode which = ios_base::in | ios_base::out);
basic_stringbuf(basic_stringbuf&& rhs);
basic_stringbuf(basic_stringbuf&& rhs, const Allocator& a);
basic_stringbuf& operator=(basic_stringbuf&& rhs);
void swap(basic_stringbuf& rhs) noexcept(see below);
template<class charT, class traits, class Allocator>
void swap(basic_stringbuf<charT, traits, Allocator>& x,
basic_stringbuf<charT, traits, Allocator>& y) noexcept(noexcept(x.swap(y)));
void init_buf_ptrs(); // exposition only
allocator_type get_allocator() const noexcept;
basic_string<charT, traits, Allocator> str() const &;
template<class SAlloc>
basic_string<charT, traits, SAlloc> str(const SAlloc& sa) const;
basic_string<charT, traits, Allocator> str() &&;
basic_string_view<charT, traits> view() const noexcept;
void str(const basic_string<charT, traits, Allocator>& s);
template<class SAlloc>
void str(const basic_string<charT, traits, SAlloc>& s);
void str(basic_string<charT, traits, Allocator>&& s);
int_type underflow() override;
int_type pbackfail(int_type c = traits::eof()) override;
int_type overflow(int_type c = traits::eof()) override;
pos_type seekoff(off_type off, ios_base::seekdir way,
ios_base::openmode which
= ios_base::in | ios_base::out) override;
Conditions | Result | |
ios_base::in is set in which | positions the input sequence | |
ios_base::out is set in which | positions the output sequence | |
both ios_base::in and ios_base::out are
set in which and either way == ios_base::beg or way == ios_base::end | positions both the input and the output sequences | |
Otherwise | the positioning operation fails. |
pos_type seekpos(pos_type sp,
ios_base::openmode which
= ios_base::in | ios_base::out) override;