std::is_error_code_enum
From 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 など)である場合、このテンプレートはメンバ定数 value を提供し、その値は true となります。それ以外の型の場合、value は false となります。
このテンプレートは、プログラム定義型に対して特殊化することで、その型が std::error_code への暗黙的変換に適格であることを示すことができます。
目次 |
[編集] ヘルパー変数テンプレート
| template< class T > constexpr bool is_error_code_enum_v = is_error_code_enum<T>::value; |
(C++17以降) | |
std::integral_constant から継承
メンバ定数
| value [static] |
T がエラーコード列挙型の場合は true、それ以外の場合は false(公開静的メンバ定数) |
メンバ関数
| operator bool |
オブジェクトを bool に変換し、value を返します。 (public member function) |
| operator() (C++14) |
value を返します。 (public member function) |
メンバ型
| 型 | 定義 |
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 として識別する (クラステンプレート) |