首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往

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)

二次

代码语言:javascript
复制
#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";
    }
}

二次

产出:

二次

代码语言:javascript
复制
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)

代码语言:txt
复制
 ? cppreference.com

在CreativeCommonsAttribution下授权-ShareAlike未移植许可v3.0。

扫码关注腾讯云开发者

领取腾讯云代金券

http://www.vxiaotou.com