storage_ptr::make_shared_resource

Return shared ownership of a new, dynamically allocated memory resource.

Synopsis

Defined in header <boost/json/storage_ptr.hpp>.

template<
    class U,
    class... Args>
storage_ptr
make_shared_resource(
    Args&&... args);

Description

This function dynamically allocates a new memory resource as if by operator new that uses shared ownership. The lifetime of the memory resource will be extended until the last storage_ptr which points to it is destroyed.

Mandates

std::is_base_of< boost::container::pmr::memory_resource, U >::value == true

Complexity

Same as new U( std::forward<Args>(args)... ).

Exception Safety

Strong guarantee.

Template Parameters

Type Description

U

The type of memory resource to create.

Parameters

Name Description

args

Parameters forwarded to the constructor of U.

Convenience header <boost/json.hpp>