c++ - 如何比较系统和通用类别中的 std::error_code?
问题描述
我的印象是,我应该能够以下面的方式比较系统类别和通用类别错误。我错过了什么吗?当我使用 gcc 执行此操作时,它们比较不相等。
#include <iostream>
#include <system_error>
int main()
{
std::error_code s{ENOSPC, std::system_category()};
auto g = std::errc::no_space_on_device;
std::cout << (g == s) << std::endl;
}
解决方案
这是 gcc 中的一个错误。如here所述,它已在最新版本中得到纠正。已在所有活动分支上修复,因此将在 6.5、7.4、8.3 和 9.1 版本中修复。
推荐阅读
- reactjs - Onesignal 命中通知客户门户到管理门户
- google-apps-script - CURL XHR Google App Script - 我想不通
- php - Symfony 5:如何在集成测试中模拟 HttpClientInterface?
- php - 如何显示在 laravel 中上传的文件?
- .net-core - 从命令行修复 dotnet core 的代码样式规则
- ant-design-pro - 使用 antdesignpro 自定义语言环境
- linux - u-boot:cmd mdtparts 找不到 nor0
- github - 添加依赖项?
- java - 如何处理精度点?
- java - 卡夫卡 - 突触