std::is_error_code_enum
来自cppreference.com
< cpp | error | error code
在标头 <system_error> 定义 | ||
template<class T > struct is_error_code_enum; | (C++11 起) | |
如果 T
是错误码枚举(例如 std::io_errc 和 std::future_errc),那么此模板提供等于 true 的成员常量 value。对于任何其他类型,value 是 false。
此模板可以为有程序定义的类型特化,以指示该类型适用 std::error_code 隐式转换。
目录 |
[编辑]辅助变量模板
template<class T > constexprbool is_error_code_enum_v = is_error_code_enum<T>::value; | (C++17 起) | |
继承自 std::integral_constant
成员常量
value [静态] | 如果 T 是错误码枚举那么是 true,否则是 false(公开静态成员常量) |
成员函数
operator bool | 将对象转换到 bool,返回 value (公开成员函数) |
operator() (C++14) | 返回 value (公开成员函数) |
成员类型
类型 | 定义 |
value_type | bool |
type | std::integral_constant<bool, value> |
运行此代码
#include <ios>#include <system_error> static_assert(std::is_error_code_enum_v<decltype(std::io_errc::stream)>); static_assert(!std::is_error_code_enum_v<std::error_category>); int main(){}
[编辑]参阅
(C++11) | 鉴别枚举是否可作为 std::error_condition (类模板) |