std::weak_ptr::lock
Da cppreference.com.
|
|
Questa pagina è stata tradotta in modo automatico dalla versione in ineglese della wiki usando Google Translate.
La traduzione potrebbe contenere errori e termini strani. Muovi il puntatore sopra al testo per vedere la versione originale. Puoi aiutarci a correggere gli gli errori. Per ulteriori istruzioni clicca qui. |
<metanoindex/>
<tbody> </tbody> std::shared_ptr<T> lock() const |
(dal C++11) | |
Crea una nuova
shared_ptr che condivide la proprietà dell'oggetto gestito. Se non c'è oggetto gestito, cioè *this è vuoto, allora il shared_ptr restituito è vuoto.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.
Restituisce efficacemente
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.
Parametri
(Nessuno)
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.
Valore di ritorno
Un
shared_ptr che condivide la proprietà dell'oggetto di proprietà.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.
Eccezioni
Note
Sia questa funzione e il costruttore di shared_ptr può essere utilizzato per acquisire la proprietà temporanea dell'oggetto gestito. La differenza è che il costruttore di
std::shared_ptr<T> genera un'eccezione quando l'argomento std::weak_ptr è vuoto, mentre std::weak_ptr<T>::lock() costruisce un std::shared_ptr<T> vuoto.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.
Esempio
| This section is incomplete Reason: no example |
Vedi anche
Verifica se l'oggetto di riferimento è già stato cancellato 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. (metodo pubblico) | |