std::future_error
Da 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. |
Definido no cabeçalho <future>
|
||
class future_error; |
(desde C++11) | |
O std::future_error classe define um objeto de exceção que é acionada em caso de falha das funções na biblioteca thread que lidam com a execução assíncrona e estados compartilhada (std::future, std::promise, etc). Similar ao std::system_error, esta excepção carrega um código de erro compatível com std::error_code.
Original:
The class std::future_error defines an exception object that is thrown on failure by the functions in the thread library that deal with asynchronous execution and shared states (std::future, std::promise, etc). Similar to std::system_error, this exception carries an error code compatible with std::error_code.
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.
Índice |
[editar] Funções de membro
cria um objeto std::future_error Original: creates a std::future_error objectThe text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (função pública membro) | |
retorna o código de erro Original: returns the error code The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (função pública membro) | |
retorna a seqüência explicativa específica para o código de erro Original: returns the explanatory string specific to the error code The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (função pública membro) |
Herdado de std::logic_error
Herdado de std::exception
Member functions
[virtual] |
destrói o objeto de exceção Original: destructs the exception object The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (of std::exception função pública virtual membro)
|
[virtual] |
retorna uma cadeia explicativa Original: returns an explanatory string The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (of std::exception função pública virtual membro)
|
[editar] Exemplo
#include <future> #include <iostream> int main() { std::future<int> empty; try { int n = empty.get(); } catch (const std::future_error& e) { std::cout << "Caught a future_error with code \"" << e.code() << "\"\nMessage: \"" << e.what() << "\"\n"; } }
Saída:
Caught a future_error with code "future:3" Message: "No associated state"
[editar] Veja também
(C++11) |
identifica os códigos de erro do futuro Original: identifies the future error codes The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (enum) |