Return a shared_ptr managing a newly created object.

Synopsis

Declared in <bslstl_sharedptr.h>

template<
    class ELEMENT_TYPE,
    class ALLOC>
bsl::shared_ptr<ELEMENT_TYPE>
allocate_shared_for_overwrite(ALLOC* basicAllocator)
requires !is_array<ELEMENT_TYPE>::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 default‐constructed. If basicAllocator is 0, then the default allocator will be used instead.

Return Value

shared pointer managing a newly created object

Parameters

Name

Description

basicAllocator

allocator used to supply memory

Created with MrDocs