allocate_unique, like std::allocate_shared but for std::unique_ptr

Synopsis

Declared in <folly/Memory.h>

template<
    typename T,
    typename Alloc,
    typename... Args>
std::unique_ptr<T, allocator_delete<std::allocator_traits<Alloc>::rebind_alloc<T>>>
allocate_unique(
    Alloc const& alloc,
    Args&&... args);

Return Value

a unique_ptr owning the object, with an allocator‐aware deleter

Parameters

Name

Description

alloc

the allocator used to allocate and construct the object

args

the arguments forwarded to the constructor of T

Created with MrDocs