std::weak_ptr::lock
De 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. |
<metanoindex/>
<tbody> </tbody> std::shared_ptr<T> lock() const |
(depuis C++11) | |
Crée un nouveau
shared_ptr qui partage la propriété de l'objet géré. S'il n'y a pas d'objet géré, c'est à dire *this est vide, alors le shared_ptr retournée est aussi vide .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.
Retourne effectivement
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.
Paramètres
(Aucun)
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.
Retourne la valeur
Un
shared_ptr qui partage la propriété de l'objet possédé .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.
Exceptions
Notes
Tant cette fonction et le constructeur de shared_ptr peuvent être utilisés pour acquérir la propriété temporaire de l'objet géré. La différence est que le constructeur de
std::shared_ptr<T> lève une exception si l'argument est vide std::weak_ptr, tandis que std::weak_ptr<T>::lock() construit une std::shared_ptr<T> vide .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.
Exemple
| This section is incomplete Reason: no example |
Voir aussi
vérifie si l'objet référencé a déjà été supprimé 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. (fonction membre publique) | |