std::exception_ptr
De 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. |
Déclaré dans l'en-tête <exception> | ||
typedef/*unspecified*/ exception_ptr; | (depuis C++11) | |
std::exception_ptr
est un nullable pointeur comme le type qui gère un objet d'exception qui a été levée et capturé avec std::current_exception. Une instance de std::exception_ptr
peut être transmise à une autre fonction, peut-être sur un autre thread, où l'exception peut-être relancée et manipulé avec une clause catch .Original:
std::exception_ptr
is a nullable pointer-like type that manages an exception object which has been thrown and captured with std::current_exception. An instance of std::exception_ptr
may be passed to another function, possibly on another thread, where the exception may be rethrown and handled with a catch clause.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.
Par défaut, construit
std::exception_ptr
est un pointeur NULL, il ne pointe pas vers un objet d'exception .Original:
Default-constructed
std::exception_ptr
is a null pointer, it does not point to an exception object.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.
Deux instances de
std::exception_ptr
comparer égales seulement si elles sont à la fois nulle ou deux points à l'objet même exception .Original:
Two instances of
std::exception_ptr
compare equal only if they are both null or both point at the same exception object.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::exception_ptr
n'est pas convertible implicitement en aucun calcul, dénombrement, ou de type pointeur. Il est convertible en bool
.Original:
std::exception_ptr
is not implicitly convertible to any arithmetic, enumeration, or pointer type. It is convertible to bool
.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.
L'objet exception référencée par une
std::exception_ptr
reste valable tant qu'il reste au moins un std::exception_ptr
qui est son référencement: std::exception_ptr
est un pointeur la copropriété intelligente .Original:
The exception object referenced by an
std::exception_ptr
remains valid as long as there remains at least one std::exception_ptr
that is referencing it: std::exception_ptr
is a shared-ownership smart pointer.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.
[modifier]Exemple
#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(conststd::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
Résultat :
Caught exception "basic_string::at"
[modifier]Voir aussi
(C++11) | crée un std::exception_ptr à partir d'un objet d'exception Original: creates an std::exception_ptr from an exception object The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (fonction générique) |
(C++11) | capture l'exception en cours dans un std::exception_ptr Original: captures the current exception in a 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. (fonction) |
(C++11) | lève l'exception d'un std::exception_ptr Original: throws the exception from an 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. (fonction) |