std::allocator_traits::allocate - cppreference.com

##### cppreference.com

##### Search

Create account

##### Namespaces

- Page
- Discussion

##### Variants

##### Views

- View
- Edit
- History

##### Actions

# std::allocator_traits::allocate

From cppreference.com
< cpp‎ | memory‎ | allocator traits

Defined in header `<memory>` |  |
static pointer allocate( Alloc& a, size_type n ); | (1) | (since C++11)
static pointer allocate( Alloc& a, size_type n, const_void_pointer hint ); | (2) | (since C++11)

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)

### [edit] Parameters

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

### [edit] Return value

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

### [edit] See also

allocate | allocates uninitialized storage (public member function of `std::allocator`) [edit]

Retrieved from "http://en.cppreference.com/mwiki/index.php?title=cpp/memory/allocator_traits/allocate&oldid=62767"