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.
Declared in <bslstl_sharedptr.h>
template<class ELEMENT_TYPE>
class enable_shared_from_this;
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] | Constructors |
~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 | Provides the implementation of a signaler. This object has a 1-1 relationship with the Signaler, which has a shared pointer to it. This allows other objects to refer to it via shared and weak pointers. This allows SignalerConnection objects to outlive the `Signaler - Signaler_Node` pair, since they can test or lock weak pointers to see if the Signaler_Node still exists when they are trying to disconnect themselves. |