std::bad_exception
ja.cppreference.net より
| ヘッダ <exception>
|
||
class bad_exception;
|
||
std::bad_exception で定義されています。
|
のインスタンスとなります。 |
|
が投げられます。 |
(C++17まで)
|
継承図 |
です。 |
メンバー関数
bad_exceptionオブジェクトを構築する
(public member function) |
|
|
オブジェクトをコピーする
(public member function) |
|
|
[virtual]
|
説明文字列を返す
(virtual public member function) |
std::exception から継承 std:: exception
メンバ関数
|
[virtual]
|
例外オブジェクトを破棄
( std::exception の仮想公開メンバ関数)
|
|
[virtual]
|
説明文字列を返す
( std::exception の仮想公開メンバ関数)
|
注記
| 機能テスト マクロ | 値 | 標準 | 機能 |
|---|---|---|---|
__cpp_lib_constexpr_exceptions
|
202411L
|
(C++26) | constexpr 例外型のためのconstexpr |
例
C++14またはそれ以前のモードでのみコンパイルされます(警告が発行される場合があります)。
このコードを実行
#include <exception> #include <iostream> #include <stdexcept> void my_unexp() { throw; } void test() throw(std::bad_exception) // Dynamic exception specifications // are deprecated in C++11 { throw std::runtime_error("test"); } int main() { std::set_unexpected(my_unexp); // Deprecated in C++11, removed in C++17 try { test(); } catch (const std::bad_exception& e) { std::cerr << "Caught " << e.what() << '\n'; } }
出力例:
Caught std::bad_exception