function
<ios> <iostream>
std::uppercase
ios_base& uppercase (ios_base& str);
Generate upper-case letters
Sets the uppercase format flag for the str stream.
When the uppercase format flag is set, uppercase (capital) letters are used instead of lowercase for representations on output operations involving stream-generated letters, like some hexadecimal representations and numerical base prefixes.
This flag can be unset with the nouppercase manipulator, not forcing the use of uppercase for generated letters.
For standard streams, the uppercase flag is not set on initialization.
Parameters
- str
- Stream object whose format flag is affected.
Because this function is a manipulator, it is designed to be used alone with no arguments in conjunction with the insertion (<<
) and extraction (>>
) operations on streams (see example below).
Return Value
Argument str.
Example
1 2 3 4 5 6 7 8 9
|
// modify uppercase flag
#include <iostream> // std::cout, std::showbase, std::hex
// std::uppercase, std::nouppercase
int main () {
std::cout << std::showbase << std::hex;
std::cout << std::uppercase << 77 << '\n';
std::cout << std::nouppercase << 77 << '\n';
return 0;
}
|
Possible output:
Data races
Modifies str. Concurrent access to the same stream object may cause data races.
Exception safety
Basic guarantee: if an exception is thrown, str is in a valid state.