「cpp/io/basic ios/bad」の版間の差分
提供: cppreference.com
細 (Use {{lc}}. Update links. Various fixes.) |
細 (Fix some translations) |
||
20行: | 20行: | ||
===パラメータ=== | ===パラメータ=== | ||
− | + | () | |
===値を返します=== | ===値を返します=== | ||
28行: | 28行: | ||
{{example template|cpp/io/basic_ios/example1}} | {{example template|cpp/io/basic_ios/example1}} | ||
− | === | + | ====== |
{{cpp/io/basic ios/iostate accessors}} | {{cpp/io/basic ios/iostate accessors}} | ||
2015年11月30日 (月) 06:14時点における版
![]() |
このページは、Google 翻訳を使って英語版から機械翻訳されました。
翻訳には誤りや奇妙な言い回しがあるかもしれません。文章の上にポインタをおくと、元の文章が見れます。誤りを修正して翻訳を改善する手助けをしてください。翻訳についての説明は、ここをクリックしてください。 |
bool bad() const; |
||
戻りtrue回復不可能なエラーが関連付けられたストリームで発生した場合。具体的には、戻りtrue
badbit
がrdstate()で設定されている場合.Original:
Returns true if non-recoverable error has occurred on the associated stream. Specifically, returns true if
badbit
is set in rdstate().The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
標準ライブラリには、次のような状況でbadbitを設定します
Original:
The standard library sets badbit in the following situations:
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
- (プット)やwrite()は、出力ストリームへの挿入は、何らかの理由で失敗した.Original:Insertion into the output stream by put() or write() fails for any reason.The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions. - 演算子<<によって出力ストリームへの挿入、またはstd::put_moneystd::put_time、出力ストリームの最後に(そのようなnum_put::put()またはmoney_put::put()としてファセットのフォーマット出力機能、イテレータを返すよう
iter
iter.failed()==trueこと)に達したため完了できませんでしたOriginal:Insertion into the output stream by 演算子<<, std::put_money or std::put_time, could not complete because the end of the output stream was reached (The facet's formatting output function such as num_put::put() or money_put::put(), returns an iteratoriter
such that iter.failed()==true)The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions. - ストリームはRDBUFにNULLポインター()を使用して構築されている、またはプットバック()/ unget()はヌルRDBUF()、または演算子<<(basic_streambuf※)に渡されるNULLポインタをストリーム上で呼ばれていますOriginal:Stream is constructed with a null pointer for rdbuf(), or putback()/unget() is called on a stream with a null rdbuf(), or a null pointer passed to operator<<(basic_streambuf*)The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions. - RDBUF() - > sputbackc()またはRDBUF() - > sungetc()の戻り形質:: eof()をプットバック()またはunget(へ)Original:rdbuf()->sputbackc() or rdbuf()->sungetc() return traits::eof() to putback() or unget()The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions. - フラッシュする> pubsync()が返す-1同期するように()、()、またはostreamのデストラクタへ:: unitbufストリーム上の歩哨 - RDBUF()Original:rdbuf()->pubsync() returns -1 to sync(), to flush(), or to the destructor of ostream::sentry on a unitbuf streamThe text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions. - 例外は、(、)sgetc(例えばsbumpc()、xsputn()オーバーフロー()など)は、関連するストリームバッファの任意のメンバ関数でI / O操作中にスローされますOriginal:Exception is thrown during an I/O operation by any member function of the associated stream buffer (e.g. sbumpc(), xsputn(), sgetc(), overflow(), etc)The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions. - 例外はiword()やpword()(例えばstd :: bad_allocだけ)にスローされますOriginal:Exception is thrown in iword() or pword() (e.g. std::bad_alloc)The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
目次 |
パラメータ
(なし)
値を返します
true回復不能なエラーが発生した場合、falseその他のとき.
Original:
true if a non-recoverable error has occurred, false otherwise.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
例
Run this code
#include <iostream> #include <fstream> #include <cstdlib> int main() { std::ifstream file("test.txt"); if(!file) // operator! is used here { std::cout << "File opening failed\n"; return EXIT_FAILURE; } // typical C++ I/O loop uses the return value of the I/O function // as the loop controlling condition, operator bool() is used here for(int n; file >> n; ) { std::cout << n << ' '; } std::cout << '\n'; if (file.bad()) std::cout << "I/O error while reading\n"; else if (file.eof()) std::cout << "End of file reached successfully\n"; else if (file.fail()) std::cout << "Non-integer data encountered\n"; }
参照
以下の表は ios_base::iostate フラグのすべての有り得る組み合わせに対する basic_ios
のアクセサ (good()、 fail() など) の値を示します。
ios_base::iostate のフラグ | basic_ios のアクセサ
| |||||||
eofbit | failbit | badbit | good() | fail() | bad() | eof() | operator bool | operator! |
false | false | false | true | false | false | false | true | false |
false | false | true | false | true | true | false | false | true |
false | true | false | false | true | false | false | false | true |
false | true | true | false | true | true | false | false | true |
true | false | false | false | false | false | true | true | false |
true | false | true | false | true | true | true | false | true |
true | true | false | false | true | false | true | false | true |
true | true | true | false | true | true | true | false | true |