[#bsl-dynamic_pointer_cast]
= xref:bsl.adoc[bsl]::dynamic&lowbar;pointer&lowbar;cast
:relfileprefix: ../
:mrdocs:

Return a `shared&lowbar;ptr&lt;TO&lowbar;TYPE&gt;` object sharing ownership of the same object as the specified `source` shared pointer to the (template parameter) `FROM&lowbar;TYPE`, and referring to `dynamic&lowbar;cast&lt;TO&lowbar;TYPE&ast;&gt;(source&period;get())`&period; If `source` cannot be dynamically cast to `TO&lowbar;TYPE &ast;`, then an empty `shared&lowbar;ptr&lt;TO&lowbar;TYPE&gt;` object is returned&period;

== Synopsis

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

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;
    class TO&lowbar;TYPE,
    class FROM&lowbar;TYPE&gt;
xref:bsl/shared_ptr-0a.adoc[bsl::shared&lowbar;ptr&lt;TO&lowbar;TYPE&gt;]
dynamic&lowbar;pointer&lowbar;cast(xref:bsl/shared_ptr-0a.adoc[shared&lowbar;ptr&lt;FROM&lowbar;TYPE&gt;] const& source) noexcept;
----


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