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.

Synopsis

Declared in <bslstl_sharedptr.h>

template<
    class DELETER,
    class ALLOCATOR>
shared_ptr(
    nullptr_t nullPointerLiteral,
    DELETER deleter,
    ALLOCATOR basicAllocator,
    ALLOCATOR::value_type* = 0);

Created with MrDocs