std:: bad_exception
From cppreference.net
C++
Utilities library
|
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Diagnostics library
|
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
std::bad_exception
| Member functions | ||||
|
定義済みヘッダー
<exception>
|
||
|
class
bad_exception
:
public
exception
|
||
std::bad_exception
は、以下の状況でC++ランタイムによってスローされる例外の型です:
|
(C++11以降) |
|
(C++17まで) |
継承図
|
|
(C++26以降) |
目次 |
メンバー関数
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