std::system_error::system_error
ja.cppreference.net から
system_error( std::error_code ec );
|
(1) | (C++11 から) |
system_error( std::error_code ec, const std::string& what_arg );
|
(2) | (C++11 から) |
system_error( std::error_code ec, const char* what_arg );
|
(2) | (C++11 から) |
system_error( int ev, const std::error_category& ecat );
|
(3) | (C++11 から) |
system_error( int ev, const std::error_category& ecat,
const std::string& what_arg );
|
(4) | (C++11 から) |
system_error( int ev, const std::error_category& ecat,
const char* what_arg );
|
(4) | (C++11 から) |
system_error( const system_error& other ) noexcept;
|
(5) | (C++11 から) |
新しいシステムエラーオブジェクトを構築します。
1) エラーコード
ec。2) エラーコード
ec と説明文字列 what_arg を用いて構築します。返される文字列は what() には what_arg が部分文字列として含まれます。3) 基になるエラーコード
ev と関連するエラーカテゴリ ecat。4) 基になるエラーコード
ev 、関連するエラーカテゴリ ecat と説明文字列 what_arg を用いて構築します。返される文字列は what() には what_arg が部分文字列として含まれます(ただし、埋め込みヌル文字が含まれていない場合)。5) コピーコンストラクタ。内容を
other の内容で初期化します。もし *this と other は両方とも動的型 std::system_error の場合、 std::strcmp(what(), other.what()) == 0。パラメータ
| ec | - | エラーコード |
| ev | - | ecat に関連付けられた列挙型の基盤となるエラーコード |
| ecat | - | エラーのカテゴリ |
| what_arg | - | 説明文字列 |
| other | - |
コピーする別のsystem_error
|
例
system_error例外を
errno
値から作成する方法を示します。
このコードを実行
#include <iostream> #include <system_error> int main() { try { throw std::system_error(EDOM, std::generic_category(), "FIX ME"); } catch (const std::system_error& ex) { std::cout << "code: [" << ex.code() << "]\n" "message: [" << ex.code().message() << "]\n" "what: [" << ex.what() << "]\n"; } }
出力例:
code: [generic:33] message: [Numerical argument out of domain] what: [FIX ME: Numerical argument out of domain]