[#bsl-shared_ptr-0a-2constructor-0d5]
= 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`, refers to the specified `ptr` cast to a pointer to the (template parameter) type `ELEMENT&lowbar;TYPE`, and uses the specified `deleter` to delete the shared object when all references have been released&period; Use the currently installed default allocator to allocate and deallocate the internal representation of the shared pointer, unless `DELETER` is a class derived from either `bslma&colon;&colon;Allocator` or `bslma&colon;&colon;SharedPtrRep`&semi; if `DELETER` is a class derived from `bslma&colon;&colon;allocator`, create a shared pointer as if calling the constructor&colon; &grave; template &lt;class CONVERTIBLE&lowbar;TYPE&gt; shared&lowbar;ptr(CONVERTIBLE&lowbar;TYPE &ast;ptr, BloombergLP&colon;&colon;bslma&colon;&colon;Allocator &ast;basicAllocator)&semi; &grave; If `DELETER` is a class derived from `bslma&colon;&colon;SharedPtrRep`, create a shared pointer as if calling the constructor&colon; &grave; shared&lowbar;ptr(ELEMENT&lowbar;TYPE &ast;ptr, BloombergLP&colon;&colon;bslma&colon;&colon;SharedPtrRep &ast;rep)&semi; &grave; If `DELETER` does not derive from either `bslma&colon;&colon;Allocator` or `BloombergLP&colon;&colon;bslma&colon;&colon;SharedPtrRep`, then `deleter` shall be a pointer to a factory object that exposes a member function that can be invoked as `deleteObject(ptr)` that will be called to destroy the object at the `ptr` address (i&period;e&period;, `deleter&hyphen;&gt;deleteObject(ptr)` will be called to delete the shared object)&period; (See the &quot;Deleters&quot; section in the component&hyphen;level documentation&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 the null pointer will be reference counted, and the deleter will be called when the last reference is destroyed&period; If an exception is thrown when allocating storage for the internal representation, then `deleter(ptr)` will be called&period; Note that this method is a BDE extension and not part of the C&plus;&plus; standard interface&period;

== Synopsis

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

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;
    class CONVERTIBLE&lowbar;TYPE,
    class DELETER&gt;
shared&lowbar;ptr(
    CONVERTIBLE&lowbar;TYPE* ptr,
    DELETER* deleter);
----


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