std::allocator::allocate
来自cppreference.com
|
|
This page has been machine-translated from the English version of the wiki using Google Translate.
The translation may contain errors and awkward wording. Hover over text to see the original version. You can help to fix errors and improve the translation. For instructions click here. |
| pointer allocate( size_type n, std::allocator<void>::const_pointer hint = 0 ); |
||
分配n * sizeof(T)字节的未初始化的存储通过调用::operator new(std::size_t),但它是不确定的,这个函数被调用时,如何。指针
hint可用于提供地方参考:分配器,如果支持的实施,将试图靠近可能hint分配新的内存块。.Original:
Allocates n * sizeof(T) bytes of uninitialized storage by calling ::operator new(std::size_t), but it is unspecified when and how this function is called. The pointer
hint may be used to provide locality of reference: the allocator, if supported by the implementation, will attempt to allocate the new memory block as close as possible to hint.The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
目录 |
[编辑] 参数
| n | - | 的对象的数目来分配存储空间
Original: the number of objects to allocate storage for The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
| hint | - | 附近的一个内存位置的指针
Original: pointer to a nearby memory location The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
[编辑] 返回值
适当对齐的存储器块的第一个字节的指针,并足以保持
nT类型的对象的一个数组.Original:
Pointer to the first byte of a memory block suitably aligned and sufficient to hold an array of
n objects of type T.The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
[编辑] 例外
如果分配失败,抛出std::bad_alloc.
Original:
Throws std::bad_alloc if allocation fails.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
[编辑] 另请参阅
| [静态的] </ SPAN></div></div>
|
分配未初始化的存储,使用分配器 Original: allocates uninitialized storage using the allocator The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (公共静态成员函数of std::allocator_traits)
|