std::iostream_category
来自cppreference.com
|
|
This page has been machine-translated from the English version of the wiki using Google Translate.
The translation may contain errors and awkward wording. Hover over text to see the original version. You can help to fix errors and improve the translation. For instructions click here. |
| Defined in header <ios>
|
||
| const std::error_category& iostream_category(); |
(C++11 起) | |
获得的静态iostream的错误的错误类对象的引用。需要重写虚函数error_category::name()返回一个指针,指向的字符串"iostream"的对象。它被用来确定提供的错误代码在例外的类型std::ios_base::failure.
Original:
Obtains a reference to the static error category object for iostream errors. The object is required to override the virtual function error_category::name() to return a pointer to the string "iostream". It is used to identify error codes provided in the exceptions of type std::ios_base::failure.
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:
(none)
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.
[编辑] 返回值
未指定的运行时类型,来自std::error_category的静态对象的参考.
Original:
A reference to the static object of unspecified runtime type, derived from std::error_category.
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.
[编辑] 例外
[编辑] 为例
#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 category: " << e.code().category().name() << '\n'; } }
Output:
Caught an ios_base::failure. Error category: iostream
[编辑] 另请参阅
| 流异常 Original: stream exception The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (公共成员类of std::ios_base)
| |
| (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. (枚举) |