public member function
<memory>
pointer allocate (size_type n, allocator<void>::const_pointer hint=0);
Allocate block of storage
Attempts to allocate a block of storage with a size large enough to contain n elements of member type value_type (an alias of the allocator's template parameter), and returns a pointer to the first element.
The storage is aligned appropriately for objects of type value_type, but they are not constructed.
In the standard default allocator, the block of storage is allocated using ::operator new one or more times, and throws bad_alloc if it cannot allocate the total amount of storage requested.
Parameters
- n
- Number of elements (each of size sizeof(value_type)) to be allocated.
The member type size_type is an alias of size_t (in the standard default allocator) size_t is an unsigned integral type.
- 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. The address of an adjacent element is often a good choice.
Return value
A pointer to the initial element in the block of storage.
pointer and const_pointer are member types (defined as aliases of T* and const T* respectively in std::allocator<T>).
The standard default allocator throws bad_alloc if it cannot allocate the requested amount of storage.