From cppreference.com
std::weak_ptr<T>weak_from_this()noexcept; (1)(since C++17)
(constexpr since C++26)std::weak_ptr<constT>weak_from_this()constnoexcept; (2)(since C++17)
(constexpr since C++26)Returns a
that tracks ownership of *this by all existing
that refer to *this.
Return value
Notes
macroValueStdFeature
__cpp_lib_enable_shared_from_this
(C++17)std::enable_shared_from_this::weak_from_thisExample
See also
(C++11)
smart pointer with shared object ownership semantics
(class template)