Mixin enabling an object to obtain a shared_ptr to itself.
Declared in <bslstl_sharedptr.h>
template<class ELEMENT_TYPE>
class enable_shared_from_this;
This class allows an object that is currently managed by a shared_ptr to safely generate a copy of the managing shared_ptr object. Inheriting from enable_shared_from_this<ELEMENT_TYPE> provides the (template parameter) ELEMENT_TYPE type with a member function shared_from_this. If an object of type ELEMENT_TYPE is managed by a shared_ptr then calling shared_from_this will return a shared_ptr<ELEMENT_TYPE> that shares ownership of that object. It is undefined behavior to call shared_from_this on an object unless that object is managed by a shared_ptr.
The intended use of enable_shared_from_this is that the (template parameter) type ELEMENT_TYPE inherits directly from the enable_shared_from_this class template. In the case of multiple inheritance, only one of the base classes should inherit from the enable_shared_from_this class template. If multiple base classes inherit from enable_shared_from_this, then there will be ambiguous calls to the shared_from_this function.
| Name | Description |
|---|---|
shared_from_this | shared_from_this overloads |
weak_from_this | weak_from_this overloads |
| Name | Description |
|---|---|
enable_shared_from_this [constructor] | Create an enable_shared_from_this object that is not owned by any shared_ptr object. |
~enable_shared_from_this [destructor] | Destroy this enable_shared_form_this. |
operator= | Return *this. This object is unchanged. Note that the specified rhs is not used. |
| Name | Description |
|---|---|
Signaler_Node | Shared implementation object backing a Signaler. |