[#BloombergLP-bslstl-SharedPtrUtil-staticCast-013]
= xref:BloombergLP.adoc[BloombergLP]::xref:BloombergLP/bslstl.adoc[bslstl]::xref:BloombergLP/bslstl/SharedPtrUtil.adoc[SharedPtrUtil]::staticCast
:relfileprefix: ../../../
:mrdocs:

`staticCast` overloads

== Synopses

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

Return a `bsl&colon;&colon;shared&lowbar;ptr&lt;TARGET&gt;` object sharing ownership of the same object as the specified `source` shared pointer to the (template parameter) `SOURCE` type, and referring to `static&lowbar;cast&lt;TARGET &ast;&gt;(source&period;get())`&period; Note that a compiler diagnostic will be emitted indicating an error unless `static&lowbar;cast&lt;TARGET &ast;&gt;(source&period;get())` is a valid expression&period;


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;
    class TARGET,
    class SOURCE&gt;
static
xref:bsl/shared_ptr-0a.adoc[bsl::shared&lowbar;ptr&lt;TARGET&gt;]
xref:BloombergLP/bslstl/SharedPtrUtil/staticCast-0b.adoc[staticCast](xref:bsl/shared_ptr-0a.adoc[bsl::shared&lowbar;ptr&lt;SOURCE&gt;] const& source) noexcept;
----

[.small]#xref:BloombergLP/bslstl/SharedPtrUtil/staticCast-0b.adoc[_» more&period;&period;&period;_]#

Load into the specified `target` an aliased shared pointer sharing ownership of the object managed by the specified `source` shared pointer and referring to `static&lowbar;cast&lt;TARGET &ast;&gt;(source&period;get())`&period; If `&ast;target` is already managing a (possibly shared) object, then release the shared reference to that object, and destroy it using its associated deleter if that shared pointer held the last shared reference to that object&period; Note that a compiler diagnostic will be emitted indicating an error unless `static&lowbar;cast&lt;TARGET &ast;&gt;(source&period;get())` is a valid expression&period;


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;
    class TARGET,
    class SOURCE&gt;
static
void
xref:BloombergLP/bslstl/SharedPtrUtil/staticCast-014.adoc[staticCast](
    xref:bsl/shared_ptr-0a.adoc[bsl::shared&lowbar;ptr&lt;TARGET&gt;]* target,
    xref:bsl/shared_ptr-0a.adoc[bsl::shared&lowbar;ptr&lt;SOURCE&gt;] const& source);
----

[.small]#xref:BloombergLP/bslstl/SharedPtrUtil/staticCast-014.adoc[_» more&period;&period;&period;_]#


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