Skip to main content

std::enable_shared_from_this<T>::weak_from_this

Since C++17
std::weak_ptr<T> weak_from_this() noexcept;                 (1)
std::weak_ptr<T const> weak_from_this() const noexcept; (2)

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

Notes

This is a copy of the private mutable weak_ptr member that is part of enable_shared_from_this.

Return value

std::weak_ptr<T> that shares ownership of *this with pre-existing std::shared_ptr

Example

This section is incomplete

std::enable_shared_from_this<T>::weak_from_this

Since C++17
std::weak_ptr<T> weak_from_this() noexcept;                 (1)
std::weak_ptr<T const> weak_from_this() const noexcept; (2)

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

Notes

This is a copy of the private mutable weak_ptr member that is part of enable_shared_from_this.

Return value

std::weak_ptr<T> that shares ownership of *this with pre-existing std::shared_ptr

Example

This section is incomplete