Daily bit(e) of C++ | std::enable_shared_from_this
Daily bit(e) of C++ #274, The C++11 mixin for obtaining access to the shared ownership of an object without access to std::shared_ptr: std::enable_shared_from_this.
When working with objects managed by std::shared_ptr, we might need to give out access to the shared ownership of this object (e.g. when working with callbacks) without access to a std::shared_ptr that holds the ownership.
The std::enable_shared_from_this mixin provides the method shared_from_this(), which returns a std::shared_ptr with access to the shared ownership.