std::basic_ios<CharT,Traits>:: rdstate
From cppreference.net
C++
Input/output library
| I/O manipulators | ||||
| Print functions (C++23) | ||||
| C-style I/O | ||||
| Buffers | ||||
|
(C++23)
|
||||
|
(
C++98/26*
)
|
||||
|
(C++20)
|
||||
| Streams | ||||
| Abstractions | ||||
| File I/O | ||||
| String I/O | ||||
| Array I/O | ||||
|
(C++23)
|
||||
|
(C++23)
|
||||
|
(C++23)
|
||||
|
(
C++98/26*
)
|
||||
|
(
C++98/26*
)
|
||||
|
(
C++98/26*
)
|
||||
| Synchronized Output | ||||
|
(C++20)
|
||||
| Types | ||||
| Error category interface | ||||
|
(C++11)
|
||||
|
(C++11)
|
std::basic_ios
| Member functions | ||||
| State functions | ||||
|
basic_ios::rdstate
|
||||
| Formatting | ||||
| Miscellaneous | ||||
| Protected member functions | ||||
|
(C++11)
|
||||
|
(C++11)
|
||||
|
(C++11)
|
|
iostate rdstate
(
)
const
;
|
||
現在のストリームエラー状態を返します。
目次 |
パラメータ
(なし)
戻り値
現在のストリームエラー状態。これはビットマスク型であり、以下の定数の組み合わせを取ることができます:
| 定数 | 説明 |
| goodbit | エラーなし |
| badbit | 回復不能なストリームエラー |
| failbit | 入出力操作の失敗(書式化または抽出エラー) |
| eofbit | 関連付けられた入力シーケンスがファイル終端に到達 |
例
このコードを実行
#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
関連項目
|
状態フラグを設定する
(公開メンバ関数) |
|
|
状態フラグを変更する
(公開メンバ関数) |