std::rethrow_exception
提供: cppreference.com
![]() |
このページは、Google 翻訳を使って英語版から機械翻訳されました。
翻訳には誤りや奇妙な言い回しがあるかもしれません。文章の上にポインタをおくと、元の文章が見れます。誤りを修正して翻訳を改善する手助けをしてください。翻訳についての説明は、ここをクリックしてください。 |
Defined in header <exception>
|
||
[[noreturn]] void rethrow_exception( std::exception_ptr p ) |
(C++11およびそれ以降) | |
例外ポインタ
p
によって参照される前に捕捉された例外オブジェクトは、スローされます.Original:
Throws the previously captured exception object, referred to by the exception pointer
p
.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.
目次 |
[編集] パラメータ
p | - | 非nullstd::exception_ptr
Original: non-null std::exception_ptr The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
[編集] 値を返します
(なし)
[編集] 例
このコードを実行します
#include <iostream> #include <string> #include <exception> #include <stdexcept> void handle_eptr(std::exception_ptr eptr) // passing by value is ok { try { if (eptr != std::exception_ptr()) { std::rethrow_exception(eptr); } } catch(const std::exception& e) { std::cout << "Caught exception \"" << e.what() << "\"\n"; } } int main() { std::exception_ptr eptr; try { std::string().at(1); // this generates an std::out_of_range } catch(...) { eptr = std::current_exception(); // capture } handle_eptr(eptr); } // destructor for std::out_of_range called here, when the eptr is destructed
出力:
Caught exception "basic_string::at"
[編集] 参照
(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) |
(C++11) |
captures the current exception in a std::exception_ptr (関数) |