std::enable_shared_from_this<T>::weak_from_this
std::weak_ptr<T> weak_from_this() noexcept; | (1) |
(начиная с C++17) (constexpr начиная с C++26) |
std::weak_ptr<const T> weak_from_this() const noexcept; | (2) |
(начиная с C++17) (constexpr начиная с C++26) |
Возвращает std::weak_ptr, отслеживающий владение *this всеми существующими std::shared_ptr, которые ссылаются на *this.
Возвращаемое значение
Примечания
| Макрос тестирования возможностей | Значение | Стандарт | Возможность |
|---|---|---|---|
__cpp_lib_enable_shared_from_this | 201603L | (C++17) |
std::enable_shared_from_this::weak_from_this |
Пример
См. также
|
(C++11) | умный указатель с семантикой совместного владения объектом (шаблон класса) |
© cppreference.com
Licensed under the Creative Commons Attribution-ShareAlike Unported License v3.0.
https://en.cppreference.com/cpp/memory/enable_shared_from_this/weak_from_this