std::basic_ios<CharT,Traits>::exceptions
提供: cppreference.com
std::ios_base::iostate exceptions()const; | (1) | |
void exceptions(std::ios_base::iostate except ); | (2) | |
ストリームの例外マスクを取得および設定します。 例外マスクは、どのエラー状態の発生時にストリームが failure 型の例外を投げるかを決定します。
1) 例外マスクを返します。
2) 例外マスクを
except
に設定します。目次 |
[編集]引数
except | - | 例外マスク |
[編集]戻り値
1) 現在の例外マスク。
2) (なし)
[編集]ノート
This section is incomplete Reason: discuss LWG2349 and link from ios_base::clear, and from (un)formatted(i/o)utputfunction requirement pages (or perhaps the behavior should be fully elaborated on the requirement pages and linked from here). See also stackoverflow.com/a/35089910 |
[編集]例
Run this code
#include <iostream>#include <fstream> int main(){int ivalue;try{std::ifstream in("in.txt"); in.exceptions(std::ifstream::failbit); in >> ivalue;}catch(std::ios_base::failure& fail){// handle exception here}}