gpt4 book ai didi

c++ - 如何比较系统和通用类别中的 std::error_code?

转载 作者:太空狗 更新时间:2023-10-29 21:32:42 27 4
gpt4 key购买 nike

我的印象是我应该能够按照下面的方式比较系统类别和一般类别错误。我错过了什么吗?当我使用 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 中的错误。如此处所述,它已在最新修订版中得到更正。在所有事件分支上已修复,因此将在 6.5、7.4、8.3 和 9.1 版本中修复。

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60555

关于c++ - 如何比较系统和通用类别中的 std::error_code?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54030973/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com