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.

Synopsis

Declared in <bslstl_sharedptr.h>

template<
    class CONVERTIBLE_TYPE,
    class DELETER>
shared_ptr(
    CONVERTIBLE_TYPE* ptr,
    DELETER deleter,
    BloombergLP::bslma::Allocator* basicAllocator = 0);

Created with MrDocs