std::system_error::system_error - cppreference.com
提供: cppreference.com
<tbody> </tbody>
|
|
(1) | (C++11以上) |
|
|
(2) | (C++11以上) |
|
|
(2) | (C++11以上) |
|
|
(3) | (C++11以上) |
|
|
(4) | (C++11以上) |
|
|
(4) | (C++11以上) |
新しいシステムエラーオブジェクトを構築します。
1) エラーコード ec を使用して構築します。
2) エラーコード ec と説明文字列 what_arg を使用して構築します。 what() によって返される文字列は what_arg を部分文字列として含むことが保証されます。
3) ベースとなるエラーコード ev および関連するエラーカテゴリ ecat を使用して構築します。
4) ベースとなるエラーコード ev、関連するエラーカテゴリ ecat および説明文字列 what_arg を使用して構築します。 what() によって返される文字列は what_arg を部分文字列として含むことが保証されます。
引数
| ec | - | エラーコード |
| ev | - | ecat に紐付く列挙の、ベースとなるエラーコード
|
| ecat | - | エラーのカテゴリ |
| what_arg | - | 説明文字列 |
例
errno の値から system_error 例外を作成する方法をデモンストレーションします。
#include <iostream> #include <system_error> int main() { try { throw std::system_error(EDOM, std::generic_category(), "hello world"); } catch (const std::system_error& ex) { std::cout << ex.code() << '\n'; std::cout << ex.code().message() << '\n'; std::cout << ex.what() << '\n'; } }
出力例:
generic:33 Numerical argument out of domain hello world: Numerical argument out of domain