std::bad_weak_ptr
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. |
definiert in Header <memory>
|
||
class bad_weak_ptr; |
(seit C++11) | |
std::bad_weak_ptr
ist die Art des Objekts als Ausnahmen von den Herstellern von std::shared_ptr, dass std::weak_ptr als Argument, wenn die std::weak_ptr zu einem bereits gelöschten Objekts bezieht sich nehmen geworfen .Original:
std::bad_weak_ptr
is the type of the object thrown as exceptions by the constructors of std::shared_ptr that take std::weak_ptr as the argument, when the std::weak_ptr refers to an already deleted 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.
Inhaltsverzeichnis |
[Bearbeiten] Member-Funktionen
baut die bad_weak_ptr ObjektOriginal: constructs the bad_weak_ptr objectThe text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (öffentliche Elementfunktion) |
Inherited from std::exception
Member functions
[virtuell] |
Zerstört das Ausnahme-Objekt Original: destructs the exception object The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (virtuellen öffentlichen Member-Funktion of std::exception )
|
[virtuell] |
gibt einen erläuternden String Original: returns an explanatory string The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (virtuellen öffentlichen Member-Funktion of std::exception )
|
[Bearbeiten] Beispiel
#include <memory> #include <iostream> int main() { std::shared_ptr<int> p1(new int(42)); std::weak_ptr<int> wp(p1); p1.reset(); try { std::shared_ptr<int> p2(wp); } catch(const std::bad_weak_ptr& e) { std::cout << e.what() << '\n'; } }
Output:
std::bad_weak_ptr
[Bearbeiten] Siehe auch
(C++11) |
intelligenter Zeiger, der geteilten Objektbesitz abbildet (Klassen-Template) |
(C++11) |
intelligenter Zeiger, der eine schwache, d.h. nicht blockierende, Referenz auf einen std::shared_ptr verwaltet (Klassen-Template) |