[#bsl-shared_ptr-0a-2constructor-093]
= xref:bsl.adoc[bsl]::xref:bsl/shared_ptr-0a.adoc[shared&lowbar;ptr]::shared&lowbar;ptr
:relfileprefix: ../../
:mrdocs:

Create a shared pointer that manages a modifiable object of (template parameter) type `CONVERTIBLE&lowbar;TYPE` and refers to the specified `ptr` cast to a pointer to the (template parameter) type `ELEMENT&lowbar;TYPE`&period; If the specified `basicAllocator` is not 0, then `basicAllocator` is used to allocate and deallocate the internal representation of the shared pointer and to destroy the shared object when all references have been released&semi; otherwise, the currently installed default allocator is used&period; If `CONVERTIBLE&lowbar;TYPE &ast;` is not implicitly convertible to `ELEMENT&lowbar;TYPE &ast;`, then a compiler diagnostic will be emitted indicating the error&period; If `ptr` is 0, then this shared pointer will still allocate an internal representation to share ownership of that empty state, which will be reclaimed when the last reference is destroyed&period; Note that if `ptr` is a null&hyphen;pointer constant, the compiler will actually select the `shared&lowbar;ptr(bsl&colon;&colon;nullptr&lowbar;t, BloombergLP&colon;&colon;bslma&colon;&colon;Allocator &ast;)` constructor, resulting in an empty shared pointer&period; Note that if `basicAllocator` is a pointer to a class derived from `bslma&colon;&colon;Allocator`, the compiler will actually select the following (more general) constructor that has the same behavior&colon; &grave; template &lt;class CONVERTIBLE&lowbar;TYPE, class DELETER&gt; shared&lowbar;ptr(CONVERTIBLE&lowbar;TYPE &ast;ptr, DELETER &ast; deleter)&semi; &grave;

== Synopsis

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

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;class CONVERTIBLE&lowbar;TYPE&gt;
shared&lowbar;ptr(
    CONVERTIBLE&lowbar;TYPE* ptr,
    xref:BloombergLP/bslma/Allocator.adoc[BloombergLP::bslma::Allocator]* basicAllocator);
----


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