std::ios_base::failure
提供: cppreference.com
![]() | このページは、Google 翻訳を使って英語版から機械翻訳されました。 翻訳には誤りや奇妙な言い回しがあるかもしれません。文章の上にポインタをおくと、元の文章が見れます。誤りを修正して翻訳を改善する手助けをしてください。翻訳についての説明は、ここをクリックしてください。 |
Defined in header <ios> | ||
class failure; | ||
クラスstd::ios_base::failureは、入力/出力ライブラリの関数で失敗した場合にスローされた例外オブジェクトを定義しています.
Original:
The class std::ios_base::failure defines an exception object that is thrown on failure by the functions in the Input/Output library.
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.
目次 |
[編集]メンバ関数
例外オブジェクトを構築します Original: constructs the exception object The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (パブリックメンバ関数) |
Inherited from std::system_error
Member functions
エラーコードを返します Original: returns error code The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (パブリックメンバ関数of std::system_error ) | |
[仮想] | 説明文字列を返します Original: returns explanatory string The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (仮想パブリックメンバ関数of std::system_error ) |
Inherited from std::runtime_error
Inherited from std::exception
Member functions
[仮想] | 例外オブジェクトを破棄します Original: destructs the exception object The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (仮想パブリックメンバ関数of std::exception ) |
[仮想] | 説明文字列を返します Original: returns an explanatory string The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (仮想パブリックメンバ関数of std::exception ) |
[編集]例
このコードを実行します
#include <iostream>#include <fstream>int main(){std::ifstream f("doesn't exist");try{ f.exceptions(f.failbit);}catch(const std::ios_base::failure& e){std::cout<<"Caught an ios_base::failure.\n"<<"Explanatory string: "<< e.what()<<'\n'<<"Error code: "<< e.code()<<'\n';}}
出力:
Caught an ios_base::failure. Explanatory string: ios_base::clear: unspecified iostream_category error Error code: iostream:1
[編集]参照
(C++11) | IOストリーム·エラー·コード Original: the IO stream error codes The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (列挙) |