名前空間
変種
操作

std::basic_ios::bad

提供: cppreference.com
< cpp‎ | io‎ | basic ios

 
 
入力/出力ライブラリ
I / Oのマニピュレータ
CスタイルのI / O
バッファ
Original:
Buffers
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
basic_streambuf
basic_filebuf
basic_stringbuf
strstreambuf(廃止予定)
ストリーム
Original:
Streams
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
抽象化
Original:
Abstractions
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
ios_base
basic_ios
basic_istream
basic_ostream
basic_iostream
ファイルI / O
Original:
File I/O
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
basic_ifstream
basic_ofstream
basic_fstream
文字列I / O
Original:
String I/O
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
basic_istringstream
basic_ostringstream
basic_stringstream
アレイのI / O
Original:
Array I/O
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
istrstream(廃止予定)
ostrstream(廃止予定)
strstream(廃止予定)
タイプ
Original:
Types
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
streamoff
streamsize
fpos
エラーカテゴリインターフェース
Original:
Error category interface
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
iostream_category(C++11)
io_errc(C++11)
 
std::basic_ios
メンバ関数
Original:
Member functions
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
basic_ios::basic_ios
basic_ios::~basic_ios
状態関数
Original:
State functions
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
basic_ios::good
basic_ios::eof
basic_ios::fail
basic_ios::bad
basic_ios::operator!
basic_ios::operator bool
basic_ios::rdstate
basic_ios::setstate
basic_ios::clear
書式
Original:
Formatting
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
basic_ios::copyfmt
basic_ios::fill
その他
Original:
Miscellaneous
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
basic_ios::exceptions
basic_ios::imbue
basic_ios::rdbuf
basic_ios::tie
basic_ios::narrow
basic_ios::widen
メンバ関数を保護しました
Original:
Protected member functions
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
basic_ios::init
basic_ios::move
basic_ios::swap
basic_ios::set_rdbuf
 
bool bad() const;
戻りtrue回復不可能なエラーが関連付けられたストリームで発生した場合。具体的には、戻りtruebadbitrdstate()で設定されている場合.
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.
標準ライブラリには、次のような状況で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.
  • (プット)や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()としてファセットのフォーマット出力機能、イテレータを返すようiteriter.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 iterator iter 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 stream
    The 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.

目次

[編集] パラメータ

(なし)
Original:
(none)
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.

[編集]

[edit]
#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 flags basic_ios accessors
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