std::weak_ptr::lock
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. |
std::shared_ptr<T> lock() const |
(desde C++11) | |
Cria um novo
shared_ptr
que partes a propriedade do objeto gerenciado. Se não houver um objeto gerenciado, ou seja *this está vazia, então o shared_ptr
voltou também está vazia.Original:
Creates a new
shared_ptr
that shares ownership of the managed object. If there is no managed object, i.e. *this is empty, then the returned shared_ptr
also is empty.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.
Efetivamente retorna expired() ? shared_ptr<T>() : shared_ptr<T>(*this).
Original:
Effectively returns expired() ? shared_ptr<T>() : shared_ptr<T>(*this).
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] 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.
You can help to correct and verify the translation. Click here for instructions.
[editar] Valor de retorno
A
shared_ptr
que compartilha a propriedade do objeto de propriedade.Original:
A
shared_ptr
which shares ownership of the owned 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.
[editar] Exceções
[editar] Notas
Tanto esta função eo construtor de shared_ptr pode ser usado para adquirir a propriedade temporária do objeto gerenciado. A diferença é que o construtor de std::shared_ptr<T> lança uma exceção quando o argumento std::weak_ptr está vazio, enquanto constrói uma std::weak_ptr<T>::lock() std::shared_ptr<T> vazio.
Original:
Both this function and the constructor of shared_ptr may be used to acquire temporary ownership of the managed object. The difference is that the constructor of std::shared_ptr<T> throws an exception when the std::weak_ptr argument is empty, while std::weak_ptr<T>::lock() constructs an empty std::shared_ptr<T>.
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.
[editar] Exemplo
Esta seção está incompleta Motivo: sem exemplo |
[editar] Veja também
Verifica se o objeto referenciado já foi excluído Original: checks whether the referenced object was already deleted 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) |