std::make_error_condition(std::io_errc)

< cpp‎ | io‎ | 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>
#include <string>
 
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++11)
IO 流的错误码
(枚举)