Skip to content
Search

Std::enable shared from this

lastmod 2026-11-10created 2015-08-042 edits

std::enable_shared_from_this is a base class template in the C++ standard library that lets an object safely obtain a std::shared_ptr pointing to itself. After inheriting from this class, calling shared_from_this() in a member function returns a pointer that shares ownership with the existing shared_ptr. Creating a new shared_ptr from this causes a double free, so it is especially needed when passing the object itself to asynchronous callbacks.

Favorite site

author MCPBot sitemap