std::setiosflags(3)
π NAME π
std::setiosflags - std::setiosflags
okay bestie, you're on the std::setiosflags(3) page from the C++ Standard Libary (that's the header's spelling, iykyk π). This is the thing that sets format flags on a stream, and we're gonna get you through it without missing a single detail β¨π
β¨ Synopsis β¨
Defined in header <iomanip> π
/*unspecified*/ setiosflags( std::ios_base::fmtflags mask );
When used in an expression out << setiosflags(mask) or in the expression in >> setiosflags(mask), it sets all format flags of the stream out or in as specified by the mask β
bestie, the return type is literally /*unspecified*/ β that's the whole vibe the page gives us π
πΈ Parameters πΈ
maskβ bitmask of the flags to set. That's your little bundle of flag bits π
π¦ Return value π¦
An object of unspecified type such that:
- if
outis an object of typestd::basic_ostream<CharT, Traits>, the expressionout << setiosflags(mask)- has type
std::basic_ostream<CharT, Traits>& - has value
out - behaves as if it called
f(out, mask)
- has type
- if
inis an object of typestd::basic_istream<CharT, Traits>, the expressionin >> setiosflags(mask)- has type
std::basic_istream<CharT, Traits>& - has value
in - behaves as if it called
f(in, mask)
- has type
where the function f is defined as:
void f(std::ios_base& str, std::ios_base::fmtflags mask)
{
// set specified flags
str.setf(mask);
}
π Example π
Run this code π
#include <iomanip>
#include <iostream>
int main()
{
std::cout << std::resetiosflags(std::ios_base::dec)
<< std::setiosflags( std::ios_base::hex
| std::ios_base::uppercase
| std::ios_base::showbase) << 42 <<
'\n';
}
β Output β
0X2A
π Defect reports π
The following behavior-changing defect reports were applied retroactively to previously published C++ standards.
- DR
LWG 183β applied to C++98. Behavior as published:setiosflagscould only be used with streams of typestd::ostreamorstd::istream. Correct behavior: usable with any character stream.
π See also π
setfβ sets specific format flag (public member function ofstd::ios_base)resetiosflagsβ clears the specifiedios_baseflags (function)
that's the whole page, bestie π«Ά source: http://cppreference.com; version/date: 2024.06.10 β and yes, this was the std::setiosflags(3) manual tea βπ
π¦ where this page comes from
- nixpkgs unstable: stdman 2024.07.05
- opensuse-leap 16.0: stdman 2024.07.05-bp160.1.9 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms