std::basic_ios::setstate(3)
β¨ NAME β¨
hii bestie!! π welcome to std::basic_ios::setstate(3) from the C++ Standard Libary (yes, that spelling, we are respecting the source, periodt π
).
std::basic_ios::setstate - std::basic_ios::setstate
okay so the name is literally the same thing twice β iconic redundancy, no cap π.
πΈ Synopsis πΈ
void setstate( iostate state );
Sets the stream error flags state in addition to currently set flags. Essentially it calls clear(rdstate() | state). May throw an exception, so donβt act brand new about it π.
π Parameters π
state is the stream error state flags to set. It can be a combination of the following constants, bestie:
Constant Explanation:
goodbitβ no errorbadbitβ irrecoverable stream errorfailbitβ input/output operation failed (formatting or extraction error)eofbitβ associated input sequence has reached end-of-file
β¨ Return value β¨
(none) β literally no return value, she gives nothing back and thatβs on periodt π
.
π Example π
Run this code, bestie:
#include <iostream>
#include <sstream>
int main()
{
std::ostringstream stream;
if (!stream.fail())
std::cout << "stream is not fail\n";
stream.setstate(std::ios_base::failbit);
if (stream.fail())
std::cout << "now stream is fail\n";
if (!stream.good())
std::cout << "and stream is not good\n";
}
Output:
stream is not fail
now stream is fail
and stream is not good
π¦ See also π¦
rdstateβ returns state flags (public member function)clearβ modifies state flags (public member function)
xoxo, your fave unix bestie π β source/version: http://cppreference.com; date: 2024.06.10; page: std::basic_ios::setstate(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