[#bsl-allocate_shared-01e] = xref:bsl.adoc[bsl]::allocate_shared :relfileprefix: ../ :mrdocs: Return a `shared_ptr` managing a newly created object. == Synopsis Declared in `<bslstl_sharedptr.h>` [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- template< class ELEMENT_TYPE, class ALLOC, class... ARGS> xref:bsl/shared_ptr-0a.adoc[bsl::shared_ptr<ELEMENT_TYPE>] allocate_shared( ALLOC basicAllocator, ARGS&&... args) requires !is_array<ELEMENT_TYPE>::value && !is_pointer<ALLOC>::value; ---- == Description Return a `shared_ptr` object referring to and managing a new `ELEMENT_TYPE` object. The specified `basicAllocator` will be used to supply a single contiguous region of memory holding the returned shared pointer's internal representation and the new `ELEMENT_TYPE` object, which is initialized by calling `allocator_traits<ALLOC>::construct` passing `basicAllocator`, an `ELEMENT_TYPE *` pointer to space for the new shared object, and the specified arguments `std::forward<ARGS>(args)...`. == Return Value shared pointer managing a newly created object == Parameters [cols="1,4"] |=== | Name| Description | *basicAllocator* | allocator used to supply memory | *args* | constructor arguments forwarded to the new object |=== [.small]#Created with https://www.mrdocs.com[MrDocs]#