std::make_error_condition(std::io_errc)
來自 cppreference.com
定義於標頭檔案 <ios> |
||
std::error_condition make_error_condition( std::io_errc e ) noexcept; |
(C++11 起) | |
從 std::io_errc 型別的值構造一個 std::error_condition 物件,如同透過 return std::error_condition(static_cast<int>(e), std::iostream_category())。
目錄 |
[編輯] 引數
e | - | 錯誤碼數字 |
[編輯] 返回值
一個 std::error_condition 型別的值,它包含來自 e 的錯誤碼數字,並與錯誤類別 "iostream" 關聯。
[編輯] 示例
執行此程式碼
#include <iostream> #include <system_error> int main() { std::error_condition ec = std::make_error_condition(std::io_errc::stream); std::cout << "error condition for io_errc::stream has value " << ec.value() << "\nand message \"" << ec.message() << "\"\n"; }
輸出
error condition for io_errc::stream has value 1 and message "unspecified iostream_category error"
[編輯] 缺陷報告
下列更改行為的缺陷報告追溯地應用於以前出版的 C++ 標準。
缺陷報告 | 應用於 | 釋出時的行為 | 正確的行為 |
---|---|---|---|
LWG 2087 | C++11 | make_error_condition(io_errc) 未宣告為 noexcept |
宣告為 noexcept |
[編輯] 參閱
(C++11) |
儲存可移植錯誤碼 (類) |
(C++11) |
I/O 流錯誤碼 (列舉) |