The second syntax sets the stream's format flags whose bits are set in both fmtfl and mask, and clears the format flags whose bits are set in mask but not in fmtfl, as if a call to flags ( (fmtfl & mask) | (flags() & ~mask) )
Both member functions return the value of the stream's format flags existing before the call.
The format flags of a stream affect the way data is interpreted in certain input functions and how it is written by certain output functions. See ios_base::fmtflags for the possible values of this function's arguments.
The first syntax of setf is generally used to set unary format flags: boolalpha, showbase, showpoint, showpos, skipws, unitbuf and uppercase, which can also be unset directly with unsetf.
On the other hand, the second syntax is generally used to set a value for one of the selective flags, using one of the field bitmasks as the mask argument:
| fmtfl format flag value | mask field bitmask |
|---|---|
| left, right or internal | adjustfield |
| dec, oct or hex | basefield |
| scientific or fixed | floatfield |
The parameterized manipulator setiosflags behaves in a similar manner as the single-parameter version of this member function.
Parameters
- fmtfl
- Format flags to be set. If the second syntax is used, only the bits set in both fmtfl and mask are set in the stream's format flags; the flags set in mask but not in fmtfl are cleared.
- mask
- Mask containing the flags to be modified.
Return Value
The format flags set in the stream before the call.Example
| 1 2 3 4 5 6 7 8 9 10 11 12 |
|
The execution of this example displays something similar to:
0x64 64 |
See also
| ios_base::flags | Get/set format flags (public member function) |
| ios_base::unsetf | Clear specific format flags (public member function) |
| ios_base::fmtflags | Type for stream format flags (public member type) |
| setiosflags | Set format flags (manipulator function) |
| resetiosflags | Reset format flags (manipulator function) |
