std::unique_ptr::operator bool – cppreference.com
Aus cppreference.com
<metanoindex/>
<tbody> </tbody>
|
|
(seit C++11) | |
Überprüft, ob *this besitzt ein Objekt, dh ob 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.
Parameter
(None)
Original:
(none)
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Rückgabewert
true wenn *this besitzt ein Objekt, false sonst .
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.
Ausnahmen
Beispiel
#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'; }
Output:
Siehe auch
liefert einen Zeiger auf das verwaltete Objekt Original: returns a pointer to the managed object The text has been machine-translated via Google Translate. (öffentliche Elementfunktion) [edit] | |