[#bsl-shared_ptr-0a-2constructor-03f] = xref:bsl.adoc[bsl]::xref:bsl/shared_ptr-0a.adoc[shared_ptr]::shared_ptr :relfileprefix: ../../ :mrdocs: Constructors == Synopses Declared in `<bslstl_sharedptr.h>` Create an empty shared pointer, i.e., a shared pointer with no representation that does not refer to any object and has no deleter. [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- constexpr xref:bsl/shared_ptr-0a/2constructor-08b.adoc[shared_ptr]() noexcept; ---- [.small]#xref:bsl/shared_ptr-0a/2constructor-08b.adoc[_» more..._]# Create a shared pointer that refers to and manages the same object (if any) as the specified `original` shared pointer, and uses the same deleter as `original` to destroy the shared object. Note that if `original` is empty, then an empty shared pointer is created, which may still point to an un‐managed object if `original` were constructed through an aliasing constructor. [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- xref:bsl/shared_ptr-0a/2constructor-04.adoc[shared_ptr](xref:bsl/shared_ptr-0a.adoc[shared_ptr] const& original) noexcept; ---- [.small]#xref:bsl/shared_ptr-0a/2constructor-04.adoc[_» more..._]# Create a shared pointer that manages the same modifiable object (if any) as the specified `other` shared pointer to the (template parameter) type `COMPATIBLE_TYPE`, uses the same deleter as `other` to destroy the shared object, and refers to `(ELEMENT_TYPE*)other.get()`. If `COMPATIBLE_TYPE *` is not implicitly convertible to `ELEMENT_TYPE *`, then a compiler diagnostic will be emitted indicating the error. Note that if `other` is empty, then an empty shared pointer is created, which may still point to an un‐managed object if `other` were constructed through an aliasing constructor. [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- template<class COMPATIBLE_TYPE> xref:bsl/shared_ptr-0a/2constructor-0b.adoc[shared_ptr](xref:bsl/shared_ptr-0a.adoc[shared_ptr<COMPATIBLE_TYPE>] const& other) noexcept; ---- [.small]#xref:bsl/shared_ptr-0a/2constructor-0b.adoc[_» more..._]# Create a shared pointer that refers to and assumes management of the same object (if any) as the specified `other` shared pointer to the (template parameter) type `COMPATIBLE_TYPE`, using the same deleter as `other` to destroy the shared object, and refers to `(ELEMENT_TYPE*)other.get()`. If `COMPATIBLE_TYPE *` is not implicitly convertible to `ELEMENT_TYPE *`, then a compiler diagnostic will be emitted indicating the error. Note that if `other` is empty, then an empty shared pointer is created, which may still point to an un‐managed object if `other` were constructed through an aliasing constructor. [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- template<class COMPATIBLE_TYPE> xref:bsl/shared_ptr-0a/2constructor-0731.adoc[shared_ptr](xref:bsl/shared_ptr-0a.adoc[shared_ptr<COMPATIBLE_TYPE>]&& other) noexcept; ---- [.small]#xref:bsl/shared_ptr-0a/2constructor-0731.adoc[_» more..._]# Create an empty shared pointer, i.e., a shared pointer with no representation that does not refer to any object and has no deleter. [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- constexpr xref:bsl/shared_ptr-0a/2constructor-00f.adoc[shared_ptr](xref:bsl/nullptr_t-08.adoc[bsl::nullptr_t]) noexcept; ---- [.small]#xref:bsl/shared_ptr-0a/2constructor-00f.adoc[_» more..._]# Create a shared pointer that refers to and assumes management of the same object (if any) as the specified `original` shared pointer, using the same deleter as `original` to destroy the shared object, and reset `original` to an empty state, not pointing to any object. Note that if `original` is empty, then an empty shared pointer is created, which may still point to an un‐managed object if `original` were constructed through an aliasing constructor. [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- xref:bsl/shared_ptr-0a/2constructor-077.adoc[shared_ptr](xref:BloombergLP/bslmf/MovableRef.adoc[BloombergLP::bslmf::MovableRef<shared_ptr>] original) noexcept; ---- [.small]#xref:bsl/shared_ptr-0a/2constructor-077.adoc[_» more..._]# Create a shared pointer that refers to and manages the same object as the specified `ptr` if `ptr.expired()` is `false`; otherwise, create a shared pointer in the empty state. Note that the referenced and managed objects may be different if `ptr` was created from a `shared_ptr` in an aliasing state. [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- template<class COMPATIBLE_TYPE> explicit xref:bsl/shared_ptr-0a/2constructor-08d.adoc[shared_ptr](xref:bsl/weak_ptr-0d.adoc[weak_ptr<COMPATIBLE_TYPE>] const& ptr); ---- [.small]#xref:bsl/shared_ptr-0a/2constructor-08d.adoc[_» more..._]# Create a shared pointer that manages a modifiable object of (template parameter) type `CONVERTIBLE_TYPE` and refers to the specified `(ELEMENT_TYPE *)ptr`. The currently installed default allocator is used to allocate and deallocate the internal representation of the shared pointer. When all references have been released, the object pointed to by the managed pointer will be destroyed by a call to `delete ptr`. 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 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. If an exception is thrown allocating storage for the representation, then `delete ptr` will be called. Note that if `ptr` is a null‐pointer constant, the compiler will actually select the `shared_ptr(bsl::nullptr_t)` constructor, resulting in an empty shared pointer. [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- template<class CONVERTIBLE_TYPE> explicit xref:bsl/shared_ptr-0a/2constructor-008.adoc[shared_ptr](CONVERTIBLE_TYPE* ptr); ---- [.small]#xref:bsl/shared_ptr-0a/2constructor-008.adoc[_» more..._]# Create an empty shared pointer. The specified `nullPointerLiteral` and `basicAllocator` are not used. Note that use of this constructor is equivalent to calling the default constructor. [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- xref:bsl/shared_ptr-0a/2constructor-02.adoc[shared_ptr]( xref:bsl/nullptr_t-08.adoc[nullptr_t] nullPointerLiteral, xref:BloombergLP/bslma/Allocator.adoc[BloombergLP::bslma::Allocator]* basicAllocator); ---- [.small]#xref:bsl/shared_ptr-0a/2constructor-02.adoc[_» more..._]# Create a shared pointer that takes over the management of the modifiable object of (template parameter) type `COMPATIBLE_TYPE` previously managed by the auto pointer object that the specified `autoRef` refers to; this shared pointer refers to the same object that it manages, and `delete(get())` will be called to destroy the shared object when all references have been released. Optionally specify a `basicAllocator` used to allocate and deallocate the internal representation of the shared pointer. If `basicAllocator` is 0, the currently installed default allocator is used. This function does not exist unless `COMPATIBLE_TYPE *` is convertible to `ELEMENT_TYPE *`. [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- explicit xref:bsl/shared_ptr-0a/2constructor-01.adoc[shared_ptr]( std::auto_ptr_ref<ELEMENT_TYPE> autoRef, xref:BloombergLP/bslma/Allocator.adoc[BloombergLP::bslma::Allocator]* basicAllocator = 0); ---- [.small]#xref:bsl/shared_ptr-0a/2constructor-01.adoc[_» more..._]# Create a shared pointer that takes ownership of the specified `rep` and refers to the modifiable object at the specified `ptr` address. The number of references to `rep` is _NOT_ incremented. Note that if `rep` is a pointer to a class derived from `BloombergLP::bslma::SharedPtrRep`, the compiler will actually select the following (more general) constructor that has the same behavior: ` template <class COMPATIBLE_TYPE, class DELETER> shared_ptr(COMPATIBLE_TYPE *ptr, DELETER * deleter); ` [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- xref:bsl/shared_ptr-0a/2constructor-0c.adoc[shared_ptr]( xref:bsl/shared_ptr-0a/element_type.adoc[element_type]* ptr, xref:BloombergLP/bslma/SharedPtrRep.adoc[BloombergLP::bslma::SharedPtrRep]* rep); ---- [.small]#xref:bsl/shared_ptr-0a/2constructor-0c.adoc[_» more..._]# Create a shared pointer that takes over the management of the modifiable object (if any) previously managed by the specified `managedPtr` to the (template parameter) type `CONVERTIBLE_TYPE`, and that refers to `(ELEMENT_TYPE *)managedPtr.ptr()`. The deleter used in the `managedPtr` will be used to destroy the shared object when all references have been released. Optionally specify a `basicAllocator` used to allocate and deallocate the internal representation of the shared pointer. If `basicAllocator` is 0, the currently installed default allocator is used. If `CONVERTIBLE_TYPE *` is not implicitly convertible to `ELEMENT_TYPE *`, then a compiler diagnostic will be emitted indicating the error. Note that if `managedPtr` is empty, then an empty shared pointer is created and `basicAllocator` is ignored. Also note that if `managedPtr` owns a reference to another shared object (due to a previous call to `shared_ptr<T>::managedPtr`) then no memory will be allocated, and this `shared_ptr` will adopt the `ManagedPtr`s ownership of that shared object. [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- template<class CONVERTIBLE_TYPE> xref:bsl/shared_ptr-0a/2constructor-09c.adoc[shared_ptr]( xref:BloombergLP/bslma/ManagedPtr-0fa.adoc[BloombergLP::bslma::ManagedPtr<CONVERTIBLE_TYPE>] managedPtr, xref:BloombergLP/bslma/Allocator.adoc[BloombergLP::bslma::Allocator]* basicAllocator = 0); ---- [.small]#xref:bsl/shared_ptr-0a/2constructor-09c.adoc[_» more..._]# Create a shared pointer that takes over the management of the modifiable object previously managed by the specified `autoPtr` to the (template parameter) type `CONVERTIBLE_TYPE`, and that refers to `(ELEMENT_TYPE *)autoPtr.get()`. `delete(autoPtr.release())` will be called to destroy the shared object when all references have been released. Optionally specify a `basicAllocator` used to allocate and deallocate the internal representation of the shared pointer. If `basicAllocator` is 0, the currently installed default allocator is used. If `CONVERTIBLE_TYPE *` is not implicitly convertible to `ELEMENT_TYPE *`, then a compiler diagnostic will be emitted indicating the error. [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- template<class CONVERTIBLE_TYPE> explicit xref:bsl/shared_ptr-0a/2constructor-0e.adoc[shared_ptr]( std::auto_ptr<CONVERTIBLE_TYPE>& autoPtr, xref:BloombergLP/bslma/Allocator.adoc[BloombergLP::bslma::Allocator]* basicAllocator = 0); ---- [.small]#xref:bsl/shared_ptr-0a/2constructor-0e.adoc[_» more..._]# Create a shared pointer that manages the same modifiable object (if any) as the specified `source` shared pointer to the (template parameter) type `ANY_TYPE`, and that refers to the modifiable object at the specified `object` address. The resulting shared pointer is known as an "alias" of `source`. Note that typically the objects referred to by `source` and `object` have identical lifetimes (e.g., one might be a part of the other), so that the deleter for `source` will destroy them both, but they do not necessarily have the same type. Also note that if `source` is empty, then an empty shared pointer is created, even if `object` is not null (in which case this empty shared pointer will refer to the same object as `object`). Also note that if `object` is null and `source` is not empty, then a reference‐counted null pointer alias will be created. [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- template<class ANY_TYPE> xref:bsl/shared_ptr-0a/2constructor-08c.adoc[shared_ptr]( xref:bsl/shared_ptr-0a.adoc[shared_ptr<ANY_TYPE>] const& source, ELEMENT_TYPE* object) noexcept; ---- [.small]#xref:bsl/shared_ptr-0a/2constructor-08c.adoc[_» more..._]# Create a shared pointer that manages a modifiable object of (template parameter) type `CONVERTIBLE_TYPE` and refers to the specified `ptr` cast to a pointer to the (template parameter) type `ELEMENT_TYPE`. 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; otherwise, the currently installed default allocator is used. 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 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. Note that if `ptr` is a null‐pointer constant, the compiler will actually select the `shared_ptr(bsl::nullptr_t, BloombergLP::bslma::Allocator *)` constructor, resulting in an empty shared pointer. Note that if `basicAllocator` is a pointer to a class derived from `bslma::Allocator`, the compiler will actually select the following (more general) constructor that has the same behavior: ` template <class CONVERTIBLE_TYPE, class DELETER> shared_ptr(CONVERTIBLE_TYPE *ptr, DELETER * deleter); ` [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- template<class CONVERTIBLE_TYPE> xref:bsl/shared_ptr-0a/2constructor-093.adoc[shared_ptr]( CONVERTIBLE_TYPE* ptr, xref:BloombergLP/bslma/Allocator.adoc[BloombergLP::bslma::Allocator]* basicAllocator); ---- [.small]#xref:bsl/shared_ptr-0a/2constructor-093.adoc[_» more..._]# Create a shared pointer that takes over the management of the modifiable object previously managed by the specified `adoptee` to the (template parameter) type `COMPATIBLE_TYPE`, and that refers to `(ELEMENT_TYPE *)autoPtr.get()`. `delete(autoPtr.release())` will be called to destroy the shared object when all references have been released. Optionally specify a `basicAllocator` used to allocate and deallocate the internal representation of the shared pointer. If `basicAllocator` is 0, the currently installed default allocator is used. This function does not exist unless `unique_ptr<COMPATIBLE_TYPE, DELETER>::pointer` is convertible to `ELEMENT_TYPE *`. Note that this function creates a `shared_ptr` with an unspecified deleter type that has satisfies this contract, which might not be the deleter of `rhs`, which is specified by the C++ standard. [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- template< class COMPATIBLE_TYPE, class UNIQUE_DELETER> requires is_convertible< typename std::unique_ptr<COMPATIBLE_TYPE, UNIQUE_DELETER>::pointer, ELEMENT_TYPE *>::value xref:bsl/shared_ptr-0a/2constructor-0735.adoc[shared_ptr]( std::unique_ptr<COMPATIBLE_TYPE, UNIQUE_DELETER>&& adoptee, xref:BloombergLP/bslma/Allocator.adoc[BloombergLP::bslma::Allocator]* basicAllocator = 0); ---- [.small]#xref:bsl/shared_ptr-0a/2constructor-0735.adoc[_» more..._]# 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. [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- template< class CONVERTIBLE_TYPE, class DELETER> xref:bsl/shared_ptr-0a/2constructor-0d5.adoc[shared_ptr]( CONVERTIBLE_TYPE* ptr, DELETER* deleter); ---- [.small]#xref:bsl/shared_ptr-0a/2constructor-0d5.adoc[_» more..._]# Create a shared pointer that takes ownership of the specified `rep` and refers to the modifiable object at the specified `ptr` address. The number of references to `rep` is _NOT_ incremented. The behavior is undefined unless `rep` was previously obtained from an existing `shared_ptr`, `rep‐>disposeObject` has not been called, and `rep‐>numReferences() > 0`. Note that this constructor is intended for use by `weak_ptr::lock`, and it would be surprising to find another client. This solves an obscure problem that arises from unusual use of classes derived from `enable_shared_from_this`. Further note that the caller is responsible for incrementing the `numReferences` count prior to calling this constructor, in order to maintain a consistent reference count when this `shared_ptr` object releases the shared object from its management. [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- xref:bsl/shared_ptr-0a/2constructor-000.adoc[shared_ptr]( ELEMENT_TYPE* ptr, xref:BloombergLP/bslma/SharedPtrRep.adoc[BloombergLP::bslma::SharedPtrRep]* rep, xref:BloombergLP/bslstl/SharedPtr_RepFromExistingSharedPtr.adoc[BloombergLP::bslstl::SharedPtr_RepFromExistingSharedPtr]); ---- [.small]#xref:bsl/shared_ptr-0a/2constructor-000.adoc[_» more..._]# Create a shared pointer that reference‐counts the null pointer, and calls the specified `deleter` with a null pointer (i.e., invokes `deleter((ELEMENT_TYPE *)0)`) when the last shared reference is destroyed. The specified `nullPointerLiteral` is not used. Optionally specify a `basicAllocator` to allocate and deallocate the internal representation of the shared pointer (including a copy of `deleter`). If `basicAllocator` is 0, the currently installed default allocator is used. If an exception is thrown when allocating storage for the internal representation, then `deleter((ELEMENT_TYPE *)0)` will be called. 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. [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- template<class DELETER> xref:bsl/shared_ptr-0a/2constructor-088.adoc[shared_ptr]( xref:bsl/nullptr_t-08.adoc[nullptr_t] nullPointerLiteral, DELETER deleter, xref:BloombergLP/bslma/Allocator.adoc[BloombergLP::bslma::Allocator]* basicAllocator = 0); ---- [.small]#xref:bsl/shared_ptr-0a/2constructor-088.adoc[_» more..._]# Create a shared pointer that manages a modifiable object of (template parameter) type `CONVERTIBLE_TYPE`, refers to the specified `(ELEMENT_TYPE *)ptr`, and uses the specified `deleter` to delete the shared object when all references have been released. Optionally specify a `basicAllocator` to allocate and deallocate the internal representation of the shared pointer (including a copy of `deleter`). If `basicAllocator` is 0, the currently installed default allocator is used. `DELETER` shall be either a function pointer or a "factory" deleter that may be invoked to destroy the object referred to by a single argument of type `CONVERTIBLE_TYPE *` (i.e., `deleter(ptr)` or `deleter‐>deleteObject(ptr)` will be called to destroy the shared object). (See the "Deleters" section in the component‐level documentation.) If `CONVERTIBLE_TYPE *` is not implicitly convertible to `ELEMENT_TYPE *`, then this constructor will not be selected by overload resolution. 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. [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- template< class CONVERTIBLE_TYPE, class DELETER> xref:bsl/shared_ptr-0a/2constructor-038.adoc[shared_ptr]( CONVERTIBLE_TYPE* ptr, DELETER deleter, xref:BloombergLP/bslma/Allocator.adoc[BloombergLP::bslma::Allocator]* basicAllocator = 0); ---- [.small]#xref:bsl/shared_ptr-0a/2constructor-038.adoc[_» more..._]# Create a shared pointer that reference‐counts the null pointer, calls the specified `deleter` with a null pointer (i.e., invokes `deleter((ELEMENT_TYPE *)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`). The (template parameter) type `DELETER` shall be either a function pointer or a function‐like deleter (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]). The specified `nullPointerLiteral` is not used. If an exception is thrown when allocating storage for the internal representation, then `deleter((ELEMENT_TYPE *)0)` will be called. 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. Note that the final dummy parameter is a simple SFINAE check that the `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. [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- template< class DELETER, class ALLOCATOR> xref:bsl/shared_ptr-0a/2constructor-0a.adoc[shared_ptr]( xref:bsl/nullptr_t-08.adoc[nullptr_t] nullPointerLiteral, DELETER deleter, ALLOCATOR basicAllocator, ALLOCATOR::value_type* = 0); ---- [.small]#xref:bsl/shared_ptr-0a/2constructor-0a.adoc[_» more..._]# 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. [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- template< class CONVERTIBLE_TYPE, class DELETER, class ALLOCATOR> xref:bsl/shared_ptr-0a/2constructor-0dd.adoc[shared_ptr]( CONVERTIBLE_TYPE* ptr, DELETER deleter, ALLOCATOR basicAllocator, ALLOCATOR::value_type* = 0); ---- [.small]#xref:bsl/shared_ptr-0a/2constructor-0dd.adoc[_» more..._]# [.small]#Created with https://www.mrdocs.com[MrDocs]#