std::basic_ios::rdstate(3)
π
std::basic_ios::rdstate(3) π
okay so this page is from the C++ Standard Libary manual, and it's giving βtiny but iconic stream-state checkβ energy. Let's get into it, bestie π
π NAME π
std::basic_ios::rdstate β literally std::basic_ios::rdstate. That's the name. No notes. iconic π
β¨ Synopsis β¨
iostate rdstate() const;
Returns the current stream error state, fr fr π
π«Ά Parameters π«Ά
(none) β literally none, bestie. nothing to pass, nothing to stress about π
π Return value π
The return value is the current stream error state. It's a bitmask type and can be a combination of the following constants:
goodbitβ no errorbadbitβ irrecoverable stream errorfailbitβ input/output operation failed (formatting or extraction error)eofbitβ associated input sequence has reached end-of-file
like, it can be more than one vibe at once, iykyk π
πΈ Example πΈ
// Run this code
#include <iostream>
#include <sstream>
int main()
{
std::ostringstream stream;
if (stream.rdstate() == std::ios_base::goodbit)
std::cout << "stream state is goodbit\n";
stream.setstate(std::ios_base::eofbit);
// check state is exactly eofbit (no failbit and no badbit)
if (stream.rdstate() == std::ios_base::eofbit)
std::cout << "stream state is eofbit\n";
}
Output:
stream state is goodbit
stream state is eofbit
π See also π
setstateβ sets state flags (public member function)clearβ modifies state flags (public member function)
okay that's the whole page, bestie π«Ά β source: http://cppreference.com, version/date: 2024.06.10, page: std::basic_ios::rdstate(3). periodt β¨
π¦ 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