std::is_error_code_enum<std::io_errc>
Defined in header <ios> | | |
---|---|---|
template< > struct is_error_code_enum<std::io_errc> : public std::true_type { }; | | (since C++11) |
这种专业化std::is_error_code_enum
通知其他库组件类型的值。std::io_errc
是保存错误代码的枚举,这使得它们隐式可转换并可分配给类型对象。std::error_code
...
继承自STD:积分[医]常量
成员常数
value static | true (public static member constant) |
---|
成员函数
operator bool | converts the object to bool, returns value (public member function) |
---|---|
operator() (C++14) | returns value (public member function) |
成员类型
Type | Definition |
---|---|
value_type | bool |
type | std::integral_constant<bool, value> |
例
比较e.code()
和std::io_errc::stream
编译是因为std::is_error_code_enum<std::io_errc>::value==true
...
二次
#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
二次
另见
is_error_code_enum (C++11) | identifies a class as an error_code enumeration (class template) |
---|---|
error_code (C++11) | holds a platform-dependent error code (class) |
io_errc (C++11) | the IO stream error codes (enum) |
© cppreference.com
在CreativeCommonsAttribution下授权-ShareAlike未移植许可v3.0。
本文档系腾讯云开发者社区成员共同维护,如有问题请联系 cloudcommunity@tencent.com