bsl::shared_ptr::shared_ptr

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.

Synopsis

Declared in <bslstl_sharedptr.h>

template<class ANY_TYPE>
shared_ptr(
    shared_ptr<ANY_TYPE> const& source,
    ELEMENT_TYPE* object) noexcept;