std::resetiosflags(3)
π std::resetiosflags(3) β C++ Standard Libary π
std::resetiosflags β yep, the NAME is literally std::resetiosflags; that's the whole name, bestie. Iconic behavior, minimal branding.
π¦ Synopsis π¦
Defined in header <iomanip>:
/*unspecified*/ resetiosflags( std::ios_base::fmtflags mask );
When you use it in an expression like out << resetiosflags(mask) or in >> resetiosflags(mask), it clears all format flags of the stream out or in as specified by the mask. It's giving "clean slate" energy, fr fr.
π Parameters π
maskβ bitmask of the flags to clear. That's the whole parameter. Slay.
β¨ Return value β¨
An object of unspecified type such that:
- if
outis an object of typestd::basic_ostream<CharT, Traits>, the expression
out << resetiosflags(mask)
- has type
std::basic_ostream<CharT, Traits>& - has value
out - behaves as if it called
f(out, mask)
- if
inis an object of typestd::basic_istream<CharT, Traits>, the expression
in >> resetiosflags(mask)
- has type
std::basic_istream<CharT, Traits>& - has value
in - behaves as if it called
f(in, mask)
where the function f is defined as:
void f(std::ios_base& str, std::ios_base::fmtflags mask)
{
// reset specified flags
str.setf(ios_base::fmtflags(0), mask);
}
The return type is literally unspecified β do not try to name it, bestie. The vibe is "trust the manipulator," not "collect the type." π
π Example π
The page says // Run this code β so run it, bestie:
#include <iomanip>
#include <iostream>
#include <sstream>
int main()
{
std::istringstream in("10 010 10 010 10 010");
int n1, n2;
in >> std::oct >> n1 >> n2;
std::cout << "Parsing \"10 010\" with std::oct gives: " << n1 << ' ' << n2 << '\n';
in >> std::dec >> n1 >> n2;
std::cout << "Parsing \"10 010\" with std::dec gives: " << n1 << ' ' << n2 << '\n';
in >> std::resetiosflags(std::ios_base::basefield) >> n1 >> n2;
std::cout << "Parsing \"10 010\" with autodetect gives: " << n1 << ' ' << n2 << '\n';
}
π Output π
Parsing "10 010" with std::oct gives: 8 8
Parsing "10 010" with std::dec gives: 10 10
Parsing "10 010" with autodetect gives: 10 8
π§ 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:resetiosflagscould only be used with streams of typestd::ostreamorstd::istream. Correct behavior: usable with any character stream. Glow-up confirmed. π
π See also π
setfβ sets specific format flag; public member function ofstd::ios_base.setiosflagsβ sets the specifiedios_baseflags; function.
With love from cppreference.com, version 2024.06.10, page std::resetiosflags(3) π
π¦ 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