[#bsl-enable_shared_from_this]
= xref:bsl.adoc[bsl]::enable&lowbar;shared&lowbar;from&lowbar;this
:relfileprefix: ../
:mrdocs:

This class allows an object that is currently managed by a `shared&lowbar;ptr` to safely generate a copy of the managing `shared&lowbar;ptr` object&period; Inheriting from `enable&lowbar;shared&lowbar;from&lowbar;this&lt;ELEMENT&lowbar;TYPE&gt;` provides the (template parameter) `ELEMENT&lowbar;TYPE` type with a member function `shared&lowbar;from&lowbar;this`&period; If an object of type `ELEMENT&lowbar;TYPE` is managed by a `shared&lowbar;ptr` then calling `shared&lowbar;from&lowbar;this` will return a `shared&lowbar;ptr&lt;ELEMENT&lowbar;TYPE&gt;` that shares ownership of that object&period; It is undefined behavior to call `shared&lowbar;from&lowbar;this` on an object unless that object is managed by a `shared&lowbar;ptr`&period;

== Synopsis

Declared in `&lt;bslstl&lowbar;sharedptr&period;h&gt;`

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;class ELEMENT&lowbar;TYPE&gt;
class enable&lowbar;shared&lowbar;from&lowbar;this;
----

== Description

The intended use of `enable&lowbar;shared&lowbar;from&lowbar;this` is that the (template parameter) type `ELEMENT&lowbar;TYPE` inherits directly from the `enable&lowbar;shared&lowbar;from&lowbar;this` class template&period; In the case of multiple inheritance, only one of the base classes should inherit from the `enable&lowbar;shared&lowbar;from&lowbar;this` class template&period; If multiple base classes inherit from `enable&lowbar;shared&lowbar;from&lowbar;this`, then there will be ambiguous calls to the `shared&lowbar;from&lowbar;this` function&period;

== Member Functions

[cols="1,4"]
|===
| Name| Description
| xref:bsl/enable_shared_from_this/shared_from_this-0a2.adoc[`shared&lowbar;from&lowbar;this`] 
| `shared&lowbar;from&lowbar;this` overloads
| xref:bsl/enable_shared_from_this/weak_from_this-0e.adoc[`weak&lowbar;from&lowbar;this`] 
| `weak&lowbar;from&lowbar;this` overloads
|===


== Protected Member Functions

[cols="1,4"]
|===
| Name| Description
| xref:bsl/enable_shared_from_this/2constructor-0a.adoc[`enable&lowbar;shared&lowbar;from&lowbar;this`]         [.small]#[constructor]#
| Constructors
| xref:bsl/enable_shared_from_this/2destructor.adoc[`&#126;enable&lowbar;shared&lowbar;from&lowbar;this`] [.small]#[destructor]#
| Destroy this `enable&lowbar;shared&lowbar;form&lowbar;this`&period;
| xref:bsl/enable_shared_from_this/operator_assign.adoc[`operator&equals;`] 
| Return `&ast;this`&period; This object is unchanged&period; Note that the specified `rhs` is not used&period;
|===


== Derived Classes

[cols="1,4"]
|===
| Name| Description
| xref:BloombergLP/bdlmt/Signaler_Node.adoc[`Signaler&lowbar;Node`] 
| Provides the implementation of a signaler&period; This object has a 1&hyphen;1 relationship with the `Signaler`, which has a shared pointer to it&period; This allows other objects to refer to it via shared and weak pointers&period; This allows `SignalerConnection` objects to outlive the &grave;Signaler &hyphen; Signaler&lowbar;Node&grave; pair, since they can test or lock weak pointers to see if the `Signaler&lowbar;Node` still exists when they are trying to disconnect themselves&period;
|===


[.small]#Created with https://www.mrdocs.com[MrDocs]#
