CppDS.com

C++ 98 11 14 17 20 手册

std::make_error_condition(std::errc)

来自cppreference.com
< cpp‎ | error‎ | errc
 
 
工具库
通用工具
日期和时间
函数对象
格式化库 (C++20)
(C++11)
关系运算符 (C++20 中弃用)
整数比较函数
(C++20)
swap 与类型运算
(C++14)
(C++11)
(C++11)
(C++11)
(C++17)
常用词汇类型
(C++11)
(C++17)
(C++17)
(C++17)
(C++17)

初等字符串转换
(C++17)
(C++17)
 
 
std::errc
非成员函数
make_error_condition
帮助类
 
定义于头文件 <system_error>
std::error_condition make_error_condition( std::errc e ) noexcept;
(C++11 起)

errce 创建一个 error_condition 。设置错误码为 int(e) ,错误类别为 std::generic_category

参数

e - 标准错误码

返回值

e 的错误条件。

示例

#include <system_error>
#include <string>
#include <iostream>
 
int main()
{
    auto err = std::make_error_condition(std::errc::invalid_argument);
    std::cout << err.message() << '\n';
}

可能的输出:

Invalid argument
关闭