std::allocator_traits<Alloc>::allocate (3) - Linux Manuals

std::allocator_traits<Alloc>::allocate: std::allocator_traits<Alloc>::allocate

NAME

std::allocator_traits<Alloc>::allocate - std::allocator_traits<Alloc>::allocate

Synopsis


Defined in header <memory>
static pointer allocate( Alloc& a, size_type n ); (since C++11)
                                                                        (until C++20)
[[nodiscard]] static pointer allocate( Alloc& a, size_type n ); (since C++20)
static pointer allocate( Alloc& a, size_type n, (1) (since C++11)
const_void_pointer hint ); (2) (until C++20)
[[nodiscard]] static pointer allocate( Alloc& a, size_type n, (since C++20)
const_void_pointer hint );


Uses the allocator a to allocate n*sizeof(Alloc::value_type) bytes of uninitialized storage.
1) Calls a.allocate(n)
2) Additionally passes memory locality hint hint. Calls a.allocate(n, hint) if possible. If not possible (e.g. a has no two-argument member function allocate()), calls a.allocate(n)

Parameters


a - allocator to use
n - the number of objects to allocate storage for
hint - pointer to a nearby memory location

Return value


The pointer returned by the call to a.allocate(n)

See also


         allocates uninitialized storage
allocate (public member function of std::allocator<T>)