31 Input/output library [input.output]

31.5 Iostreams base classes [iostreams.base]

31.5.2 Class ios_base [ios.base]

31.5.2.1 General [ios.base.general]

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 noreplace = 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 idx); void*& pword(int idx); // destructor virtual ~ios_base(); // [ios.base.callback], callbacks enum event { 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 }; }
ios_base defines several member types:
  • a type failure, defined as either a class derived from system_error or a synonym for a class derived from system_error;
  • a class Init;
  • three bitmask types, fmtflags, iostate, and openmode;
  • an enumerated type, seekdir.
It maintains several kinds of data:
  • state information that reflects the integrity of the stream buffer;
  • control information that influences how to interpret (format) input sequences and how to generate (format) output sequences;
  • additional information that is stored by the program for its private use.
[Note 1: 
For the sake of exposition, the maintained data is presented here as:
  • 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;
  • long* iarray, points to the first element of an arbitrary-length long array maintained for the private use of the program;
  • void** parray, points to the first element of an arbitrary-length pointer array maintained for the private use of the program.
— end note]