public static member function
<memory>

std::allocator_traits::allocate

static pointer allocate (allocator_type& alloc, size_type n);
static pointer allocate (allocator_type& alloc, size_type n, const_void_pointer hint);
Allocate block of storage
Uses allocator alloc to attempt the allocation of a block of storage with a size large enough to contain n elements properly aligned, and returns a pointer to the first element.

No element objects are constructed by the call (see allocator_traits::construct).

In the non-specialized definition of allocator_traits, this member function simply calls alloc.allocate(n) (or alloc.allocate(n,hint)) to achieve this functionality, but a specialization for a specific allocator type may provide a different definition.

Parameters

alloc
Allocator object
allocator_type is an alias of allocator_traits's template parameter.
n
Number of elements to be allocated.
size_type is a member type of allocator_traits.
hint
Either 0 or a value previously obtained by another call to allocate and not yet freed with deallocate.
When it is not 0, this value may be used as a hint to improve performance by allocating the new block near the one specified.
const_void_pointer is a member type of allocator_traits.

Return value

A pointer to the location of the first element in the block of storage.

pointer is a member type of allocator_traits.

See also