C++ iomanip Library - setiosflags Function
Description
The C++ function std::setiosflags behaves as if member setf were called with mask as argument on the stream on which it is inserted/extracted as a manipulator (it can be inserted/extracted on input streams or output streams).
It is used to sets the format flags specified by parameter mask.
Declaration
Following is the declaration for std::setiosflags function.
setiosflags (ios_base::fmtflags mask);
Parameters
mask − Mask representing the flags to be set. fmtflags is a bitmask type.
Return Value
It returns unspecified. This function should only be used as a stream manipulator.
Exceptions
Basic guarantee − if an exception is thrown, the stream is in a valid state.
Data races
The stream object on which it is inserted/extracted is modified. Concurrent access to the same stream object may introduce data races.
Example
In below example explains about setiosflag function.
#include <iostream>
#include <iomanip>
int main () {
std::cout << std::hex;
std::cout << std::setiosflags (std::ios::showbase | std::ios::uppercase);
std::cout << 100 << std::endl;
return 0;
}
Let us compile and run the above program, this will produce the following result −
0X64
iomanip.htm