std::bad_weak_ptr
De cppreference.com
<metanoindex/>
<tbody> </tbody>| Definido no cabeçalho <memory>
|
||
class bad_weak_ptr; |
(desde C++11) | |
std::bad_weak_ptr é o tipo do objeto lançado como exceções pelos construtores de std::shared_ptr que levam std::weak_ptr como argumento, quando o std::weak_ptr refere-se a um objeto já eliminado.Original:
std::bad_weak_ptr is the type of the object thrown as exceptions by the constructors of std::shared_ptr that take std::weak_ptr as the argument, when the std::weak_ptr refers to an already deleted 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.
Inheritance diagram
Funções de membro
constrói o objeto bad_weak_ptrOriginal: constructs the bad_weak_ptr 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) | |
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)
|
Exemplo
#include <memory>
#include <iostream>
int main()
{
std::shared_ptr<int> p1(new int(42));
std::weak_ptr<int> wp(p1);
p1.reset();
try {
std::shared_ptr<int> p2(wp);
} catch(const std::bad_weak_ptr& e) {
std::cout << e.what() << '\n';
}
}
Saída:
std::bad_weak_ptr
