cpp/io/basic ios/exceptions
来自cppreference.com
std::ios_base::iostate exceptions() const; |
||
void exceptions(std::ios_base::iostate except); |
||
[编辑] 参数
except | - | 异常掩码
|
[编辑] 示例
#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 } }