std:: make_error_condition (std::io_errc)
|
定义于头文件
<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)
|
IO流错误代码
(枚举) |