std::basic_ios<CharT,Traits>:: setstate
From cppreference.net
|
void
setstate
(
iostate state
)
;
|
||
ストリームのエラーフラグ state を現在設定されているフラグに追加して設定します。本質的には clear ( rdstate ( ) | state ) を呼び出します。例外をスローする可能性があります。
目次 |
パラメータ
| state | - |
設定するストリームエラーステートフラグ。以下の定数の組み合わせを指定可能:
|
戻り値
(なし)
例
このコードを実行
#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"; }
出力:
stream is not fail now stream is fail and stream is not good
関連項目
|
状態フラグを返す
(公開メンバ関数) |
|
|
状態フラグを変更する
(公開メンバ関数) |