Return a shared_ptr managing a newly created object.
Synopsis
Declared in <bslstl_sharedptr.h>
template<
class ARRAY_TYPE,
class ALLOC>
bsl::shared_ptr<ARRAY_TYPE>
allocate_shared(
ALLOC basicAllocator,
std::size_t numElements)
requires is_unbounded_array<ARRAY_TYPE>::value &&
!is_pointer<ALLOC>::value;
Description
Return a shared_ptr object referring to and managing a new ARRAY_TYPE object, where ARRAY_TYPE is a unbounded array. 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 ARRAY_TYPE containing the specified numElements number of elements, and each element in the array is default constructed.
Return Value
shared pointer managing a newly created object
Parameters
Name |
Description |
basicAllocator |
allocator used to supply memory |
numElements |
number of elements in the unbounded array |
Created with MrDocs