##### cppreference.com

##### Search

Create account

##### Namespaces

- Page
- Discussion

##### Variants

##### Views

- View
- Edit
- History

##### Actions

# std::enable_shared_from_this::weak_from_this

From cppreference.com
< cpp‎ | memory‎ | enable shared from this

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

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

### [edit] Notes

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

### [edit] Return value

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

### [edit] Exceptions

2)
`noexcept` specification:
noexcept

### [edit] Example

| This section is incomplete Reason: no example

### [edit] See also

shared_ptr (C++11) | smart pointer with shared object ownership semantics (class template) [edit]

Retrieved from "http://en.cppreference.com/mwiki/index.php?title=cpp/memory/enable_shared_from_this/weak_from_this&oldid=91641"
Categories:

- unconditionally noexcept
- Todo no example

Hidden categories:

- Pages with unreviewed unconditional noexcept template
- Pages with unreviewed noexcept template