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

Create a `shared&lowbar;ptr` owning null with a deleter and allocator&period;

== Synopsis

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

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;
    class DELETER,
    class ALLOCATOR&gt;
shared&lowbar;ptr(
    xref:bsl/nullptr_t-08.adoc[nullptr&lowbar;t] nullPointerLiteral,
    DELETER deleter,
    ALLOCATOR basicAllocator,
    ALLOCATOR::value&lowbar;type* sfinae = 0);
----

== Description

Create a shared pointer that reference&hyphen;counts the null pointer, calls the specified `deleter` with a null pointer (i&period;e&period;, invokes `deleter((ELEMENT&lowbar;TYPE &ast;)0)`) when the last shared reference is destroyed, and uses the specified `basicAllocator` to allocate and deallocate the internal representation of the shared pointer (including a copy of the `deleter`)&period; The (template parameter) type `DELETER` shall be either a function pointer or a function&hyphen;like deleter (See the &quot;Deleters&quot; section in the component&hyphen; level documentation)&period; The (template parameter) type `ALLOCATOR` shall satisfy the Allocator requirements of the C&plus;&plus; standard (C&plus;&plus;11 17&period;6&period;3&period;5, &lsqb;allocator&period;requirements&rsqb;)&period; The specified `nullPointerLiteral` is not used&period; If an exception is thrown when allocating storage for the internal representation, then `deleter((ELEMENT&lowbar;TYPE &ast;)0)` will be called&period; The behavior is undefined unless `deleter` can be called with a null pointer, and unless the constructor making a copy of `deleter` does not throw an exception&period; Note that the final dummy parameter is a simple SFINAE check that the `ALLOCATOR` type probably satisfies the standard allocator requirements&semi; in particular, it will not match pointer types, so any pointers to `bslma&colon;&colon;Allocator` derived classes will dispatch to the constructor above this, and not be greedily matched to a generic type parameter&period;

== Parameters

[cols="1,4"]
|===
| Name| Description
| *nullPointerLiteral*
| null&hyphen;pointer literal (unused&semi; selects this overload)
| *deleter*
| deleter invoked when the last shared reference is released
| *basicAllocator*
| allocator used to supply memory
| *sfinae*
| unused SFINAE discriminator
|===


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