std::basic_ios<CharT,Traits>::setstate
提供: cppreference.com
void setstate( iostate state ); |
||
現在セットされているフラグに追加でストリームのエラーフラグ state
をセットします。 実質的に clear(rdstate() | state) を呼びます。 例外を投げるかもしれません。
目次 |
[編集] 引数
state | - | セットするストリームのエラー状態フラグ。 以下の定数を組み合わせることができます。
|
[編集] 戻り値
(なし)
[編集] 例
Run this code
#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
[編集] 関連項目
状態フラグを返します (パブリックメンバ関数) | |
状態フラグを変更します (パブリックメンバ関数) |