[#bsl-shared_ptr-0a-2constructor-09c]
= xref:bsl.adoc[bsl]::xref:bsl/shared_ptr-0a.adoc[shared&lowbar;ptr]::shared&lowbar;ptr
:relfileprefix: ../../
:mrdocs:

Create a `shared&lowbar;ptr` by adopting ownership from a managed pointer&period;

== Synopsis

Declared in `&lt;bslstl&lowbar;sharedptr&period;h&gt;`

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;class CONVERTIBLE&lowbar;TYPE&gt;
shared&lowbar;ptr(
    xref:BloombergLP/bslma/ManagedPtr-0fa.adoc[BloombergLP::bslma::ManagedPtr&lt;CONVERTIBLE&lowbar;TYPE&gt;] managedPtr,
    xref:BloombergLP/bslma/Allocator.adoc[BloombergLP::bslma::Allocator]* basicAllocator = 0);
----

== Description

Create a shared pointer that takes over the management of the modifiable object (if any) previously managed by the specified `managedPtr` to the (template parameter) type `CONVERTIBLE&lowbar;TYPE`, and that refers to `(ELEMENT&lowbar;TYPE &ast;)managedPtr&period;ptr()`&period; The deleter used in the `managedPtr` will be used to destroy the shared object when all references have been released&period; Optionally specify a `basicAllocator` used to allocate and deallocate the internal representation of the shared pointer&period; If `basicAllocator` is 0, the currently installed default allocator is used&period; If `CONVERTIBLE&lowbar;TYPE &ast;` is not implicitly convertible to `ELEMENT&lowbar;TYPE &ast;`, then a compiler diagnostic will be emitted indicating the error&period; Note that if `managedPtr` is empty, then an empty shared pointer is created and `basicAllocator` is ignored&period; Also note that if `managedPtr` owns a reference to another shared object (due to a previous call to `shared&lowbar;ptr&lt;T&gt;&colon;&colon;managedPtr`) then no memory will be allocated, and this `shared&lowbar;ptr` will adopt the `ManagedPtr`s ownership of that shared object&period;

== Parameters

[cols="1,4"]
|===
| Name| Description
| *managedPtr*
| managed pointer whose ownership is transferred
| *basicAllocator*
| allocator used to supply memory
|===


[.small]#Created with https://www.mrdocs.com[MrDocs]#
