bsl::make_shared

Return a shared_ptr managing a newly created object.

Synopsis

Declared in <bslstl_sharedptr.h>

template<
    class ELEMENT_TYPE,
    class... ARGS>
bsl::shared_ptr<ELEMENT_TYPE>
make_shared(ARGS&&... args)
requires !bsl::is_array<ELEMENT_TYPE>::value;

Description

Return a shared_ptr object referring to and managing a new ELEMENT_TYPE object. The default allocator 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 using the ELEMENT_TYPE constructor that takes the specified arguments std::forward<ARGS>(args).... If ELEMENT_TYPE uses bslma allocators, then the default allocator is passed as an extra argument in the final position.

Return Value

shared pointer managing a newly created object

Parameters

NameDescription
argsconstructor arguments forwarded to the new object