std::weak_ptr::expired
Aus 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. |
| bool expired() const; |
(seit C++11) | |
Überprüft, ob das verwaltete Objekt wurde bereits gelöscht. Entspricht use_count() == 0 .
Original:
Checks whether the managed object has already been deleted. Equivalent to use_count() == 0.
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.
Inhaltsverzeichnis |
[Bearbeiten] 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.
You can help to correct and verify the translation. Click here for instructions.
[Bearbeiten] Rückgabewert
true wenn das verwaltete Objekt bereits gelöscht wurde, false sonst .
Original:
true if the managed object has already been deleted, 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.
[Bearbeiten] Ausnahmen
[Bearbeiten] Notes
expired() kann schneller sein als use_count() .Original:
expired() may be faster than use_count().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.
[Bearbeiten] Beispiel
Veranschaulicht, wie abgelaufene verwendet wird, um die Gültigkeit des Zeigers überprüfen .
Original:
Demonstrates how expired is used to check validity of the pointer.
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.
#include <iostream> #include <memory> std::weak_ptr<int> gw; void f() { if (!gw.expired()) { std::cout << "gw is valid\n"; } else { std::cout << "gw is expired\n"; } } int main() { { auto sp = std::make_shared<int>(42); gw = sp; f(); } f(); }
Output:
gw is valid gw is expired
[Bearbeiten] Siehe auch
| schafft eine shared_ptr, die das referenzierte Objekt verwaltetOriginal: creates a shared_ptr that manages the referenced objectThe text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (öffentliche Elementfunktion) | |
| gibt die Anzahl der shared_ptr Objekte, die das Objekt verwalten Original: returns the number of shared_ptr objects that manage the object The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (öffentliche Elementfunktion) | |