std::io_errc
Defined in header <ios> | | |
|---|---|---|
enum class io_errc; | | (since C++11) |
范围枚举std::io_errc中的I/O流报告的错误代码。std::ios_base::failure异常对象。只有一个错误代码%28std::io_errc::stream%29是必需的,尽管实现可能定义其他错误代码。因为适当的专门化std::is_error_code_enum提供类型的值。std::io_errc隐式可转换为std::error_code...
成员常数
Enumeration constant | Value |
|---|---|
stream | 1 |
非会员职能
make_error_code(std::io_errc) (C++11) | constructs an iostream error code (function) |
|---|---|
make_error_condition(std::io_errc) (C++11) | constructs an iostream error_condition (function) |
帮助者类
is_error_code_enum<std::io_errc> (C++11) | extends the type trait std::is_error_code_enum to identify iostream error codes (class template) |
|---|
例
二次
#include <iostream>
#include <fstream>
int main()
{
std::ifstream f("doesn't exist");
try {
f.exceptions(f.failbit);
} catch (const std::ios_base::failure& e) {
std::cout << "Caught an ios_base::failure.\n";
if(e.code() == std::io_errc::stream)
std::cout << "The error code is std::io_errc::stream\n";
}
}二次
产出:
二次
Caught an ios_base::failure.
The error code is std::io_errc::stream二次
另见
error_code (C++11) | holds a platform-dependent error code (class) |
|---|---|
error_condition (C++11) | holds a portable error code (class) |
failure | stream exception (public member class of std::ios_base) |
© cppreference.com在CreativeCommonsAttribution下授权-ShareAlike未移植许可v3.0。
本文档系腾讯云开发者社区成员共同维护,如有问题请联系 cloudcommunity@tencent.com

