Create a shared_ptr by adopting ownership from a unique pointer.
Synopsis
Declared in <bslstl_sharedptr.h>
template<
class COMPATIBLE_TYPE,
class UNIQUE_DELETER>
requires is_convertible<
typename std::unique_ptr<COMPATIBLE_TYPE,
UNIQUE_DELETER>::pointer,
ELEMENT_TYPE *>::value
shared_ptr(
std::unique_ptr<COMPATIBLE_TYPE, UNIQUE_DELETER>&& adoptee,
BloombergLP::bslma::Allocator* basicAllocator = 0);
Description
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.
Parameters
Name |
Description |
adoptee |
unique pointer whose ownership is transferred |
basicAllocator |
allocator used to supply memory |
Created with MrDocs