std:: is_error_code_enum <std::io_errc>
|
定義済みヘッダー
<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::error_code 型のオブジェクトへの暗黙的な変換および代入が可能になります。
目次 |
std:: integral_constant からの継承
メンバ定数
|
value
[static]
|
true
(public static member constant) |
メンバ関数
|
operator bool
|
オブジェクトを
bool
に変換し、
value
を返す
(public member function) |
|
operator()
(C++14)
|
value
を返す
(public member function) |
メンバ型
| 型 | 定義 |
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 <fstream> #include <iostream> 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)
|
IOストリームのエラーコード
(列挙型) |