std::rethrow_exception
Aus cppreference.com
![]() |
This page has been machine-translated from the English version of the wiki using Google Translate.
The translation may contain errors and awkward wording. Hover over text to see the original version. You can help to fix errors and improve the translation. For instructions click here. |
definiert in Header <exception>
|
||
[[noreturn]] void rethrow_exception( std::exception_ptr p ) |
(seit C++11) | |
Wirft den zuvor aufgenommenen Exception-Objekt, auf das sich der Ausnahme-Zeiger
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.
Inhaltsverzeichnis |
[Bearbeiten] Parameter
p | - | Nicht-Null-std::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. |
[Bearbeiten] Rückgabewert
(None)
Original:
(none)
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.
[Bearbeiten] Beispiel
#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
Output:
Caught exception "basic_string::at"
[Bearbeiten] Siehe auch
(C++11) |
teilte Zeigertyp für den Umgang mit Exception-Objekte 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 (Funktion) |