std::make_error_condition(std::io_errc)
来自 cppreference.cn
定义于头文件 <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 流错误码 (枚举) |