Manipulators in C++
Manipulators are helper functions that make it possible to control input/output streams using operator<<()
or operator>>()
The advantage of using manipulators, inserters, and extractors over regular member functions for a class is that the stream-and-file metaphor is maintained. In the long run, this makes for code that is easier to read, maintain, and use. The supplier (writer) of a class has to do a little more work up front, but ultimately the supplier's job is made easier and the user of a class benefits immediately.
Non-Parametric Manipulators
Parametric Manipulators
These are:
setiosflags(ios_base::fmtflags mask) | Set format flags |
resetiosflags(X, Y) | Reset format flags |
setbase(X, Y) | Set basefield flag |
setfill(X, Y) | Set fill character |
setprecision(X, Y) | Set decimal precision |
setw(X, Y) | Set field width |
get_money(X, Y) | Get monetary value |
put_money(X, Y) | Put monetary value |
get_time(X, Y) | Get date and time |
put_time(X, Y) | Put date and time |