C++ ios Library - Noboolalpha Function
Description
It is used to clears the boolalpha format flag for the str stream. When the boolalpha format flag is not set, bool values are inserted/extracted as integral values (0 and 1) instead of their textual representations: true and false.
Declaration
Following is the declaration for std::noboolalpha function.
ios_base& noboolalpha (ios_base& str);
Parameters
str − Stream object whose format flag is affected.
Return Value
It returns Argument str.
Exceptions
Basic guarantee − if an exception is thrown, str is in a valid state.
Data races
It modifies str. Concurrent access to the same stream object may cause data races.
Example
In below example explains about std::noboolalpha function.
#include <iostream>
int main () {
bool b = true;
std::cout << std::boolalpha << b << '\n';
std::cout << std::noboolalpha << b << '\n';
return 0;
}
Let us compile and run the above program, this will produce the following result −
true 1
ios.htm
Advertisements