[#bsl-shared_ptr-0a-2constructor-0dd] = xref:bsl.adoc[bsl]::xref:bsl/shared_ptr-0a.adoc[shared_ptr]::shared_ptr :relfileprefix: ../../ :mrdocs: Create a shared pointer that manages a modifiable object of (template parameter) type `CONVERTIBLE_TYPE`, refers to the specified `ptr` cast to a pointer to the (template parameter) type `ELEMENT_TYPE`, and uses the specified `deleter` to delete the shared object when all references have been released. Use the specified `basicAllocator` to allocate and deallocate the internal representation of the shared pointer (including a copy of the `deleter`). The (template parameter) type `DELETER` shall be either a function pointer or a function‐like deleter that may be invoked to destroy the object referred to by a single argument of type `CONVERTIBLE_TYPE *` (i.e., `deleter(ptr)` will be called to destroy the shared object). (See the "Deleters" section in the component‐ level documentation.) The (template parameter) type `ALLOCATOR` shall satisfy the Allocator requirements of the C++ standard (C++11 17.6.3.5, [allocator.requirements]). If `CONVERTIBLE_TYPE *` is not implicitly convertible to `ELEMENT_TYPE *`, then a compiler diagnostic will be emitted indicating the error. If `ptr` is 0, then the null pointer will be reference counted, and `deleter(ptr)` will be called when the last reference is destroyed. If an exception is thrown when allocating storage for the internal representation, then `deleter(ptr)` will be called. The behavior is undefined unless the constructor making a copy of `deleter` does not throw an exception. Note that the final dummy parameter is a simple SFINAE check that the (template parameter) `ALLOCATOR` type probably satisfies the standard allocator requirements; in particular, it will not match pointer types, so any pointers to `bslma::Allocator` derived classes will dispatch to the constructor above this, and not be greedily matched to a generic type parameter. == Synopsis Declared in `<bslstl_sharedptr.h>` [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- template< class CONVERTIBLE_TYPE, class DELETER, class ALLOCATOR> shared_ptr( CONVERTIBLE_TYPE* ptr, DELETER deleter, ALLOCATOR basicAllocator, ALLOCATOR::value_type* = 0); ---- [.small]#Created with https://www.mrdocs.com[MrDocs]#