Espaços nominais
Variantes
Acções

std::current_exception

Da cppreference.com
< cpp‎ | error

 
 
Biblioteca de utilitários
Digite apoio (basic types, RTTI, type traits)
Gerenciamento de memória dinâmica
De tratamento de erros
Utilidades do programa
Variadic funções
Data e hora
Objetos de função
(C++11)
Os operadores relacionais
Original:
Relational operators
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
rel_ops::operator!=
rel_ops::operator>
rel_ops::operator<=
rel_ops::operator>=
Pares e tuplas
Original:
Pairs and tuples
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
(C++11)
Troque, avançar e avançar
Original:
Swap, forward and move
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
(C++11)
(C++11)
(C++11)
 
De tratamento de erros
Manipulação de exceção
Original:
Exception handling
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
current_exception
(C++11)
Manipulação de falhas de exceção
Original:
Exception handling failures
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
(obsoleta)
(C++11)(obsoleta)
(obsoleta)
Categorias de exceção
Original:
Exception categories
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Códigos de erro
Original:
Error codes
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Códigos de erro
Afirmações
Original:
Assertions
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
instalação system_error
Original:
system_error facility
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
(C++11)
(C++11)
 
Definido no cabeçalho <exception>
std::exception_ptr current_exception()
(desde C++11)
Se for chamado durante o tratamento de exceção (normalmente, em uma cláusula catch), capta o objeto de exceção atual e cria um std::exception_ptr que contém uma referência a esse objeto de exceção, ou de uma cópia do que objeto de exceção (que é definida pela implementação se uma cópia é feita)
Original:
If called during exception handling (typically, in a catch clause), captures the current exception object and creates an std::exception_ptr that holds a reference to that exception object, or to a copy of that exception object (it is implementation-defined if a copy is made)
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Se a implementação desta função requer uma chamada para new ea chamada falhar, o ponteiro retornado irá realizar uma referência a uma instância de std::bad_alloc
Original:
If the implementation of this function requires a call to new and the call fails, the returned pointer will hold a reference to an instance of std::bad_alloc
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Se a implementação desta função requer para copiar o objeto de exceção capturada e seu construtor cópia lança uma exceção, o ponteiro retornado irá realizar uma referência para a exceção lançada. Se o construtor de cópia do objeto exceção lançada também lança, o ponteiro retornado pode conter uma referência a uma instância de std::bad_exception para quebrar o loop infinito.
Original:
If the implementation of this function requires to copy the captured exception object and its copy constructor throws an exception, the returned pointer will hold a reference to the exception thrown. If the copy constructor of the thrown exception object also throws, the returned pointer may hold a reference to an instance of std::bad_exception to break the endless loop.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Se a função é chamada quando nenhuma exceção está sendo tratado, uma std::exception_ptr vazio é retornado.
Original:
If the function is called when no exception is being handled, an empty std::exception_ptr is returned.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

Índice

[editar]Parâmetros

(Nenhum)
Original:
(none)
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

[editar]Valor de retorno

Uma instância de std::exception_ptr mantendo uma referência para o objeto de exceção, ou uma cópia do objeto de exceção, ou a uma instância do std::bad_alloc ou a uma instância do std::bad_exception.
Original:
An instance of std::exception_ptr holding a reference to the exception object, or a copy of the exception object, or to an instance of std::bad_alloc or to an instance of std::bad_exception.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

[editar]Exceções

noexcept specification:  
noexcept
  (desde C++11)

[editar]Exemplo

#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

Saída:

Caught exception "basic_string::at"

[editar]Veja também

tipo ponteiro compartilhado para manusear objetos de exceção
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)[edit]
lança a exceção de um 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.

(função)[edit]
cria uma std::exception_ptr a partir de um objeto de exceção
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.

(modelo de função)[edit]
close