bsl::shared_ptr::shared_ptr

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.

Synopsis

Declared in <bslstl_sharedptr.h>

shared_ptr(
    ELEMENT_TYPE* ptr,
    BloombergLP::bslma::SharedPtrRep* rep,
    BloombergLP::bslstl::SharedPtr_RepFromExistingSharedPtr);