|
Stream manipulators
Manipulators are functions specifically designed to be used in conjunction with the insertion (<<) and extraction (>>) operators on stream objects, for example:
They are still regular functions and can also be called as any other function using a stream object as argument, for example:
Manipulators are used to change formatting parameters on streams and to insert or extract certain special characters.
Basic format flags
These manipulators are usable on both input and output streams, although many only have an effect when applied to either output or input streams.
Independent flags (switch on):
boolalpha | Alphanumerical bool values (manipulator function) |
showbase | Show numerical base prefixes (manipulator function) |
showpoint | Show decimal point (manipulator function) |
showpos | Show positive signs (manipulator function) |
skipws | Skip whitespaces (manipulator function) |
unitbuf | Flush buffer after insertions (manipulator function) |
uppercase | Generate upper-case letters (manipulator function) |
Independent flags (switch off):
noboolalpha | No alphanumerical bool values (manipulator function) |
noshowbase | Do not show numerical base prefixes (manipulator function) |
noshowpoint | Do not show decimal point (manipulator function) |
noshowpos | Do not show positive signs (manipulator function) |
noskipws | Do not skip whitespaces (manipulator function) |
nounitbuf | Do not force flushes after insertions (manipulator function) |
nouppercase | Do not generate upper case letters (manipulator function) |
Numerical base format flags ("basefield" flags):
dec | Use decimal base (manipulator function) |
hex | Use hexadecimal base (manipulator function) |
oct | Use octal base (manipulator function) |
Floating-point format flags ("floatfield" flags):
fixed | Use fixed-point notation (manipulator function) |
scientific | Use scientific notation (manipulator function) |
Adustment format flags ("adjustfield" flags):
internal | Adjust field by inserting characters at an internal position (manipulator function) |
left | Adjust output to the left (manipulator function) |
right | Adjust output to the right (manipulator function) |
Input manipulators
ws | Extract whitespaces (manipulator function) |
Output manipulators
endl | Insert newline and flush (manipulator function) |
ends | Insert null character (manipulator function) |
flush | Flush stream buffer (manipulator function) |
Parameterized manipulators
These functions take parameters when used as manipulators. They require the explicit inclusion of the header file <iomanip>.
setbase | Set basefield flag (manipulator function) |
setfill | Set fill character (manipulator function) |
setw | Set field width (manipulator function) |
|