std::iostream_category
性病::碘流[医]范畴
Defined in header | | |
---|---|---|
const std::error_category& iostream_category( | | (since C++11) |
获取对iostream错误的静态错误类别对象的引用。对象需要重写虚拟函数。error_category::name()
返回指向字符串的指针"iostream"
它用于识别类型异常中提供的错误代码。std::ios_base::failure
...
参数
%280%29
返回值
派生为未指定运行时类型的静态对象的引用。std::error_category
...
例外
noexcept
规格:
noexcept
例
二次
#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"
<< "Error code: " << e.code().value()
<< " (" << e.code().message() << ")\n"
<< "Error category: " << e.code().category().name() << '\n';
}
}
二次
可能的产出:
二次
Caught an ios_base::failure.
Error code: 1 (unspecified iostream_category error)
Error category: iostream
二次
另见
failure | stream exception (public member class of std::ios_base) |
---|---|
io_errc (C++11) | the IO stream error codes (enum) |
© cppreference.com
在CreativeCommonsAttribution下授权-ShareAlike未移植许可v3.0。