|
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Defined in header <memory> | ||
static pointer allocate( Alloc& a, size_type n); | (1) | (since C++11) (constexpr since C++20) |
static pointer allocate( Alloc& a, size_type n, const_void_pointer hint); | (2) | (since C++11) (constexpr since C++20) |
Uses the allocatora to allocaten* sizeof(Alloc::value_type) bytes of uninitialized storage. An array of typeAlloc::value_type[n] is created in the storage, but none of its elements are constructed.
allocate), callsa.allocate(n).Contents |
| a | - | allocator to use |
| n | - | the number of objects to allocate storage for |
| hint | - | pointer to a nearby memory location |
The pointer returned by the call toa.allocate(n).
Alloc::allocate was not required to create array object untilP0593R6, which made using non-default allocator forstd::vector and some other containers not well-defined according to a strict reading of the core language specification.
After callingallocate and before construction of elements, pointer arithmetic ofAlloc::value_type* is well-defined within the allocated array, but the behavior is undefined if elements are accessed.
| This section is incomplete Reason: no example |
| allocates uninitialized storage (public member function of std::allocator<T>)[edit] |