Base class with template-independent members for the stream class hierarchy.
iostream library  

Standard hierarchy


Public member functions:

flagsGet/set format flags.
getlocGet current locale.
imbueImbue locale.
iwordGet reference to a long element of the internal extensible array.
precisionGet/set floating-point decimal presision.
pwordGet reference to a void* element of the internal extensible array.
register_callbackRegister event callback function.
setfSet some format flags.
sync_with_stdioActivates / Deactivates synchronization with cstdio functions. [static]
unsetfClear format flag.
widthGet/set field width.
xallocReturn a new index for the internal extensible array. [static]

Note: Constructor is protected.

Member types / Nested classes:

failureBase class for stream exceptions.
fmtflagsBitmask type for format flags.
InitEmbedded class that ensures the construction of stream objects.
iostateBitmask type for state flags.
openmodeBitmask type for opening mode flags.
seekdirEnumerated-like type to indicate seeking direction.

Applicable Manipulators:

boolalphainsert/extract bool objects as names (true or false).
decinsert/extract integer values in decimal format.
fixedinsert floating-point values in fixed format.
hexinsert/extract integer values in hexadecimal format.
noboolalphainsert/extract bool objects as numeric values.
noshowbasedo not prefix value with its base.
noshowpointdo not show decimal point if not necessary.
noshowposdo not insert plus sign (+) if number is non-negative.
noskipwsdo not skip initial white space on extracting.
nounitbufdo not flush buffer after each insert operation.
nouppercasedo not replace lowercase letters by uppercase equivalents.
octinsert/extract values in octal format.
scientificinsert floating-point values in scientific format.
showbaseprefix value with its base
showpointalways show decimal point when inserting floating-point values
showposinsert plus sign (+) before every non-negative value.
skipwsskip initial white space on extracting.
unitbufflush buffer after each insert operation
uppercasereplace lowercase letters by uppercase equivalents.


  The class is designed to be a base class for all the stream classes hierarchy. It describes the most basic part of a stream which is common to all stream objects. It is not intended to be directly instantiated to objects.
  Both the ios_base class and its derived ios class define the members of every stream that are independent of wether the stream object is an input or an output stream. ios_base describes the members that are template-independent (i.e. the part that is not dependent on the type of character used by the stream) while ios describes the members that are template-dependent.

  The ios_base class is in charge of mantaining internally the following information of a stream:

Formatting information:
  • format flags: a set of flags describing how certain input/output operations shall be interpreted. It is an internal object of type ios_base::fmtflags that can be obtained/modified by calling members flags, setf and unsetf. The manipulators listed above modify individual format flags.
  • field width: describes the width of the next element to be output. It is an integer of type streamsize and may be obtained/modified by calling member width.
  • display precision: describes the decimal precision to be used to output floating-point values. It is an integer value of type streamsize and can be obtained/modified by calling member precision.
  • locale object: describes localization properties to be considered when formatting i/o operations. It is an object of type locale that can be obtained calling member getloc and modified using imbue.
State information:
  • event function stack: stack of pointers to callback functions that are called when certain events occur. Additional callback functions may be registered to be called when an even occurs, with member register_callback.
  • two internal extensible arrays: internal arrays of long objects and void pointers. To extend the array call class member xalloc, and to get references to these objects call iword or pword

© The C++ Resources Network, 2001