std::io_errc
来自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>
|
||
| enum class io_errc; |
(C++11 起) | |
範圍的列舉
std::io_errc定義報告的I / O流std::ios_base::failure異常對象的錯誤代碼。只有一個錯誤代碼(std::io_errc::stream)是必需的,雖然實現可以定義額外的錯誤代碼。由於提供相應的專業化的std :: is_error_code_enum的std::io_errc是,值類型的隱式轉換為std::error_code的Original:
The scoped enumeration
std::io_errc defines the error codes reported by I/O streams in std::ios_base::failure exception objects. Only one error code (std::io_errc::stream) is required, although the implementation may define additional error codes. Because the appropriate specialization of std::is_error_code_enum is provided, values of type std::io_errc are implicitly convertible to std::error_code.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: Enumeration constant The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
Value |
stream
|
1 |
[编辑] Helper類
| 擴展了的類型特徵std::is_error_code_enum識別iostream的錯誤代碼 Original: extends the type trait std::is_error_code_enum to identify iostream error codes The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (類模板) | |
[编辑] 非成員函數
| 構造一個iostream的錯誤代碼 Original: constructs an iostream error code The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (函數) | |
| 構建的iostream error_condition Original: constructs an iostream error_condition The text has been machine-translated via Google Translate. 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"; if(e.code() == std::io_errc::stream) std::cout << "The error code is std::io_errc::stream\n"; } }
Output:
Caught an ios_base::failure. The error code is std::io_errc::stream
[编辑] 另請參閱
| (C++11) |
持有與平台相關的錯誤代碼 Original: holds a platform-dependent error code The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (類) |
| (C++11) |
持有攜帶型的錯誤代碼 Original: holds a portable error code The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (類) |
| 流異常 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)
| |