---
name: "std::enable_shared_from_this"
section: "3cxx"
platform: "linux"
package: "libstdc++-12-doc"
version: "12.4.0-5"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/std::enable_shared_from_this/3cxx"
---

# std::enable\_shared\_from\_this(3cxx)

Base class allowing use of the member function shared\_from\_this.

## NAME

std::enable\_shared\_from\_this\< \_Tp \> - Base class allowing use of the member function `shared_from_this`.

## SYNOPSIS

`#include <memory>`

### Public Member Functions

**shared\_ptr**\< \_Tp \> **shared\_from\_this** ()\
 **shared\_ptr**\< const \_Tp \> **shared\_from\_this** () const\

**weak\_ptr**\< \_Tp \> **weak\_from\_this** () noexcept\
 **weak\_ptr**\< const \_Tp \> **weak\_from\_this** () const noexcept\

### Protected Member Functions

**enable\_shared\_from\_this** (const **enable\_shared\_from\_this** &) noexcept\
 **enable\_shared\_from\_this** & **operator=** (const **enable\_shared\_from\_this** &) noexcept\

### Friends

const **enable\_shared\_from\_this** \* **\_\_enable\_shared\_from\_this\_base** (const \_\_shared\_count\<\> &, const **enable\_shared\_from\_this** \*\_\_p)\
 template\<**typename** , \_Lock\_policy \> **class** **\_\_shared\_ptr**\

## Detailed Description

### template\<typename \_Tp\>

class std::enable\_shared\_from\_this\< \_Tp \>"Base class allowing use of the member function `shared_from_this`.

**Since**

C++11

## Member Function Documentation

### template\<typename \_Tp \> weak\_ptr\< const \_Tp \> std::enable\_shared\_from\_this\< \_Tp \>::weak\_from\_this () const` [inline]`, ` [noexcept]`

Get a `weak_ptr` referring to the object that has `*this` as its base.

**Since**

C++17

### template\<typename \_Tp \> weak\_ptr\< \_Tp \> std::enable\_shared\_from\_this\< \_Tp \>::weak\_from\_this ()` [inline]`, ` [noexcept]`

Get a `weak_ptr` referring to the object that has `*this` as its base.

**Since**

C++17

## Author

Generated automatically by Doxygen for libstdc++ from the source code.
