Namespaces
Variants

std::enable_shared_from_this<T>::weak_from_this

From cppreference.com
 
 
Memory management library
Allocators
Memory resources
Uninitialized storage (until C++20*)
Garbage collector support (until C++23)
 
 
std::weak_ptr<T> weak_from_this() noexcept;
(1) (since C++17)
(constexpr since C++26)
std::weak_ptr<const T> weak_from_this() const noexcept;
(2) (since C++17)
(constexpr since C++26)

Returns a std::weak_ptr that tracks ownership of *this by all existing std::shared_ptr that refer to *this.

Return value

weak_this

Notes

Feature-test macro Value Std Feature
__cpp_lib_enable_shared_from_this 201603L (C++17) std::enable_shared_from_this::weak_from_this

Example

See also

smart pointer with shared object ownership semantics
(class template) [edit]
Morty Proxy This is a proxified and sanitized view of the page, visit original site.