std::is_error_code_enum<std::io_errc>
提供: cppreference.com
ヘッダ <ios> で定義
|
||
template< > struct is_error_code_enum<std::io_errc> : public std::true_type { }; |
(C++11以上) | |
この std::is_error_code_enum の特殊化は std::io_errc 型の値がエラーコードを保持する列挙であることを他のライブラリコンポーネントに知らせます。 これにより std::io_errc 型の値が std::error_code 型のオブジェクトに暗黙に変換可能および代入可能になります。
目次 |
std::integral_constant から継承
メンバ定数
value [静的] |
true (パブリック静的メンバ定数) |
メンバ関数
operator bool |
オブジェクトを bool に変換します。 value を返します (パブリックメンバ関数) |
operator() (C++14) |
value を返します (パブリックメンバ関数) |
メンバ型
型 | 定義 |
value_type
|
bool
|
type
|
std::integral_constant<bool, value> |
[編集] 例
std::is_error_code_enum<std::io_errc>::value == true であるため e.code() と std::io_errc::stream の比較がコンパイルできます。
Run this code
#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
[編集] 関連項目
(C++11) |
クラスを error_code 列挙型として識別します (クラステンプレート) |
(C++11) |
プラットフォーム依存のエラーコードを保持します (クラス) |
(C++11) |
iostream のエラーコード (列挙) |