std::bad_weak_ptr
Материал из 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. |
| Заголовочный файл <memory>
|
||
| class bad_weak_ptr; |
(начиная с C++11) | |
std::bad_weak_ptr является тип объекта брошен в качестве исключения в конструкторах std::shared_ptr, которые принимают std::weak_ptr в качестве аргумента, когда std::weak_ptr относится к уже удаленному объекту.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.
Содержание |
[править] Член функций
| строит bad_weak_ptr объектаOriginal: 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. (public функция-член) | |
Унаследован от std::exception
Member functions
| [virtual] |
разрушает объект исключения 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. (virtual public std::exception функция-член)
|
| [virtual] |
возвращает пояснительной строкой 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. (virtual public std::exception функция-член)
|
[править] Пример
#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'; } }
Вывод:
std::bad_weak_ptr
[править] См. также
| (C++11) |
smart pointer with shared object ownership semantics (шаблон класса) |
| (C++11) |
слабую ссылку на объект, управляемый std::shared_ptr Original: weak reference to an object managed by std::shared_ptr The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (шаблон класса) |
