std::unique_ptr::operator bool
De cppreference.com
< cpp | memory | unique ptr
![]() |
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. |
explicit operator bool() const; |
(depuis C++11) | |
Vérifie que *this possède un objet, à savoir si get() == nullptr .
Original:
Checks whether *this owns an object, i.e. whether get() == nullptr.
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.
Sommaire |
[modifier] 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.
[modifier] Retourne la valeur
true si *this possède un objet, false autrement .
Original:
true if *this owns an object, false otherwise.
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.
[modifier] Exceptions
[modifier] Exemple
#include <iostream> #include <memory> int main() { std::unique_ptr<int> ptr(new int(42)); if (ptr) std::cout << "before reset, ptr is: " << *ptr << '\n'; ptr.reset(); if (ptr) std::cout << "after reset, ptr is: " << *ptr << '\n'; }
Résultat :
before reset, ptr is: 42
[modifier] Voir aussi
renvoie un pointeur sur l'objet géré Original: returns a pointer to the managed object 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) |