[#bsl-shared_ptr-0a-2constructor-0d5] = 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 currently installed default allocator to allocate and deallocate the internal representation of the shared pointer, unless `DELETER` is a class derived from either `bslma::Allocator` or `bslma::SharedPtrRep`; if `DELETER` is a class derived from `bslma::allocator`, create a shared pointer as if calling the constructor: ` template <class CONVERTIBLE_TYPE> shared_ptr(CONVERTIBLE_TYPE *ptr, BloombergLP::bslma::Allocator *basicAllocator); ` If `DELETER` is a class derived from `bslma::SharedPtrRep`, create a shared pointer as if calling the constructor: ` shared_ptr(ELEMENT_TYPE *ptr, BloombergLP::bslma::SharedPtrRep *rep); ` If `DELETER` does not derive from either `bslma::Allocator` or `BloombergLP::bslma::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.e., `deleter‐>deleteObject(ptr)` will be called to delete the shared object). (See the "Deleters" section in the component‐level documentation.) 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 the deleter 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. Note that this method is a BDE extension and not part of the C++ standard interface. == Synopsis Declared in `<bslstl_sharedptr.h>` [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- template< class CONVERTIBLE_TYPE, class DELETER> shared_ptr( CONVERTIBLE_TYPE* ptr, DELETER* deleter); ---- [.small]#Created with https://www.mrdocs.com[MrDocs]#