「cpp/error/bad exception」の版間の差分
提供: cppreference.com
TranslationBot (トーク | 投稿記録) (Translated from the English version using Google Translate) |
細 (→例) |
||
(4人の利用者による、間の5版が非表示) | |||
1行: | 1行: | ||
− | |||
{{cpp/title|bad_exception}} | {{cpp/title|bad_exception}} | ||
− | {{cpp/error/navbar}} | + | {{cpp/error/navbar}} |
− | {{ | + | {{begin}} |
− | {{ | + | {{header | exception}} |
− | {{ | + | {{|1= |
class bad_exception; | class bad_exception; | ||
}} | }} | ||
− | {{ | + | {{end}} |
− | + | {{tt|std::bad_exception}} C++ | |
− | + | {{ | |
− | + | || | |
− | + | {{|std::}} {{|std::}} {{tt|std::bad_exception}} | |
+ | |||
+ | | | ||
+ | [[cpp/language/except_spec|]]{{|std::unexpected}} {{tt|std::bad_exception}} {{tt|std::bad_exception}} | ||
+ | }} | ||
+ | {{}} | ||
{{inheritance diagram/std-bad_exception}} | {{inheritance diagram/std-bad_exception}} | ||
===メンバ関数=== | ===メンバ関数=== | ||
− | {{ | + | {{begin}} |
− | {{ | + | {{mem ctor | cpp/error/bad_exception/bad_exception | {{tt|bad_exception}} }} |
− | {{ | + | {{mem fun | cpp/error/bad_exception/operator{{=}} | オブジェクトをコピーします }} |
− | {{ | + | {{mem vfun | cpp/error/bad_exception/what | 説明文字列を返します }} |
− | {{ | + | {{end}} |
{{cpp/error/exception/inherit}} | {{cpp/error/exception/inherit}} | ||
51行: | 55行: | ||
} | } | ||
} | } | ||
+ | |||
| output= | | output= | ||
Caught std::bad_exception | Caught std::bad_exception | ||
}} | }} | ||
+ | |||
+ |
2020年4月25日 (土) 21:07時点における最新版
ヘッダ <exception> で定義
|
||
class bad_exception; |
||
std::bad_exception
は以下の状況で C++ ランタイムによって投げられる例外の型です。
|
(C++11以上) |
|
(C++17未満) |
目次 |
[編集] メンバ関数
bad_exception オブジェクトを構築します (パブリックメンバ関数) | |
オブジェクトをコピーします (パブリックメンバ関数) | |
[仮想] |
説明文字列を返します (仮想パブリックメンバ関数) |
std::exception から継承
メンバ関数
[仮想] |
例外オブジェクトを破棄します ( std::exception の仮想パブリックメンバ関数)
|
[仮想] |
説明文字列を返します ( std::exception の仮想パブリックメンバ関数)
|
[編集] 例
Run this code
#include <iostream> #include <exception> #include <stdexcept> void my_unexp() { throw; } void test() throw(std::bad_exception) { throw std::runtime_error("test"); } int main() { std::set_unexpected(my_unexp); try { test(); } catch(const std::bad_exception& e) { std::cerr << "Caught " << e.what() << '\n'; } }
出力例:
Caught std::bad_exception