The first form (1) returns the format flags currently selected in the stream.
The second form (2) sets new format flags for the stream, returning its former value.
The format flags of a stream affect the way data is interpreted in certain input functions and how these are written by certain output functions. See ios_base::fmtflags for the possible values of this function's argument and the interpretation of its return value.
The second form of this function sets the value for all the format flags of the stream, overwriting the existing values and clearing any flag not explicitly set in the argument. To access individual flags, see members setf and unsetf.
Parameters
fmtfl
Format flags to be used by the stream. ios_base::fmtflags is a bitmask type.
Return Value
The format flags selected in the stream before the call. ios_base::fmtflags is a bitmask type.
This simple example sets some format flags for cout that affect the insertion operation by printing the value in hexadecimal (0x64) padded right as in a field ten spaces long:
0x64
Data races
Accesses (1) or modifies (2) the stream object.
Concurrent access to the same stream object may cause data races.
Exception safety
Basic guarantee: if an exception is thrown, the stream is in a valid state.