std::basic_ios<CharT,Traits>::rdstate - cppreference.com (original) (raw)
| I/O manipulators |
|---|
| Print functions (C++23) |
| C-style I/O |
| Buffers |
| basic_streambuf |
| basic_filebuf |
| basic_stringbuf |
| basic_spanbuf(C++23) |
| strstreambuf(C++98/26*) |
| basic_syncbuf(C++20) |
| Streams |
| Abstractions |
| ios_base |
| basic_ios |
| basic_istream |
| basic_ostream |
| basic_iostream |
| File I/O |
| basic_ifstream |
| basic_ofstream |
| basic_fstream |
| String I/O |
| basic_istringstream |
| basic_ostringstream |
| basic_stringstream |
| Array I/O |
| basic_ispanstream(C++23) |
| basic_ospanstream(C++23) |
| basic_spanstream(C++23) |
| istrstream(C++98/26*) |
| ostrstream(C++98/26*) |
| strstream(C++98/26*) |
| Synchronized Output |
| basic_osyncstream(C++20) |
| Types |
| streamoff |
| streamsize |
| fpos |
| Error category interface |
| iostream_category(C++11) |
| io_errc(C++11) |
| Member functions |
|---|
| basic_ios::basic_ios |
| basic_ios::~basic_ios |
| State functions |
| basic_ios::good |
| basic_ios::eof |
| basic_ios::fail |
| basic_ios::bad |
| basic_ios::operator! |
| basic_ios::operator bool |
| basic_ios::rdstate |
| basic_ios::setstate |
| basic_ios::clear |
| Formatting |
| basic_ios::copyfmt |
| basic_ios::fill |
| Miscellaneous |
| basic_ios::exceptions |
| basic_ios::imbue |
| basic_ios::rdbuf |
| basic_ios::tie |
| basic_ios::narrow |
| basic_ios::widen |
| Protected member functions |
| basic_ios::init |
| basic_ios::move(C++11) |
| basic_ios::swap(C++11) |
| basic_ios::set_rdbuf(C++11) |
| iostate rdstate() const; | | | | ------------------------ | | |
Returns the current stream error state.
Contents
[edit] Parameters
(none)
[edit] Return value
current stream error state. It is a bitmask type and can be a combination of the following constants:
| Constant | Explanation |
|---|---|
| goodbit | no error |
| badbit | irrecoverable stream error |
| failbit | input/output operation failed (formatting or extraction error) |
| eofbit | associated input sequence has reached end-of-file |
[edit] Example
Run this code
#include #include 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
[edit] See also
| setstate | sets state flags (public member function) [edit] |
|---|---|
| clear | modifies state flags (public member function) [edit] |