std::uncaught_exception
提供: cppreference.com
![]() |
このページは、Google 翻訳を使って英語版から機械翻訳されました。
翻訳には誤りや奇妙な言い回しがあるかもしれません。文章の上にポインタをおくと、元の文章が見れます。誤りを修正して翻訳を改善する手助けをしてください。翻訳についての説明は、ここをクリックしてください。 |
Defined in header <exception>
|
||
bool uncaught_exception(); |
||
現在のスレッドが生きた例外オブジェクトであるを持っているかどうかを検出すると、例外がスローされていて、まだ一致するcatch句を入力していない、またはstd::terminatestd::unexpected。スタックの巻き戻しが現在進行中である言い換えれば、std::uncaught_exceptionを検出.
Original:
Detects if the current thread has a live exception object, that is, an exception has been thrown and not yet entered a matching catch clause, std::terminate or std::unexpected. In other words, std::uncaught_exception detects if stack unwinding is currently in progress.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
時にはstd::uncaught_exception() == true中に例外をスローするのが安全です。例外がキャッチされ、デストラクタでは無視されている場合たとえば、彼らはそこから伝播することができないとstd::terminateにつながるわけではない.
Original:
Sometimes it's safe to throw an exception even while std::uncaught_exception() == true. For example, if exceptions are caught and ignored in a destructor, they can't propagate out of it and won't lead to std::terminate.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
目次 |
[編集] パラメータ
(なし)
[編集] 値を返します
trueスタックの巻き戻しがこのスレッドで現在進行中である場合に.
Original:
true if stack unwinding is currently in progress in this thread.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
[編集] 例外
[編集] 例
このコードを実行します
#include <iostream> #include <exception> #include <stdexcept> struct Foo { ~Foo() { if (std::uncaught_exception()) { std::cout << "~Foo() called during stack unwinding\n"; } else { std::cout << "~Foo() called normally\n"; } } }; int main() { Foo f; try { Foo f; std::cout << "Exception thrown\n"; throw std::runtime_error("test exception"); } catch (const std::exception& e) { std::cout << "Exception caught: " << e.what() << '\n'; } }
出力:
Exception thrown ~Foo() called during stack unwinding Exception caught: test exception ~Foo() called normally
[編集] 参照
例外処理が失敗したときに呼び出される関数です Original: function called when exception handling fails The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (関数) | |
(C++11) |
例外オブジェクトを処理するための共有ポインタ型 Original: shared pointer type for handling exception objects The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (typedef) |