std::basic_ios::rdstate
性病:基本[医]IOS::rdstate
iostate rdstate() const; | | |
---|
返回当前流错误状态。
参数
%280%29
返回值
当前流错误状态。它是位掩码类型,可以是以下常量的组合:
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 |
例
二次
#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";
}
}
二次
产出:
二次
stream state is goodbit
stream state is eofbit
二次
另见
setstate | sets state flags (public member function) |
---|---|
clear | clears error and eof flags (public member function) |
© cppreference.com
在CreativeCommonsAttribution下授权-ShareAlike未移植许可v3.0。