std::allocator
来自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. |
| Defined in header <memory>
|
||
| template< class T > struct allocator; |
(1) | |
| template<> struct allocator<void>; |
(2) | |
std::allocator类模板是默认的Allocator使用的所有标准库容器,如果没有提供用户指定的分配器。默认的分配是无状态的,那就是,所有的分配器的情况下是可以互换的,比较平等的,可以释放分配的内存分配器类型相同的任何其他实例.Original:
The
std::allocator class template is the default Allocator used by all standard library containers if no user-specified allocator is provided. The default allocator is stateless, that is, all instances of the given allocator are interchangeable, compare equal and can deallocate memory allocated by any other instance of the same allocator type.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.
为void缺乏专业化的成员类型定义
reference,const_reference,size_type和difference_type。这种专业化声明没有成员函数.Original:
Specialization for void lacks the member typedefs
reference, const_reference, size_type and difference_type. This specialization declares no member functions.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.
| All custom allocators also must be stateless. | (至 C++11) |
| Custom allocators may contain state. Each container or another allocator-aware object stores an instance of the supplied allocator and controls allocator replacement through std::allocator_traits. | (C++11 起) |
目录 |
[编辑] 会员类型
| 类型
Original: Type The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
Definition |
value_type
|
T |
pointer
|
T* |
const_pointer
|
const T* |
reference
|
T& |
const_reference
|
const T& |
size_type
|
std::size_t |
difference_type
|
std::ptrdiff_t |
rebind
|
template< class U > struct rebind { typedef allocator<U> other; }; |
[编辑] 成员函数
| 创建一个新的allocator实例 Original: creates a new allocator instance The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (公共成员函数) | |
| 解构一个分配器实例 Original: destructs an allocator instance The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (公共成员函数) | |
| 获得的对象的地址,即使operator&被重载 Original: obtains the address of an object, even if operator& is overloaded The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (公共成员函数) | |
| 分配未初始化的存储 Original: allocates uninitialized storage The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (公共成员函数) | |
| 会释放存储空间 Original: deallocates storage The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (公共成员函数) | |
| 返回支持的最大分配的大小 Original: returns the largest supported allocation size The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (公共成员函数) | |
| 构造一个对象在分配的存储空间 Original: constructs an object in allocated storage The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (公共成员函数) | |
| 解构分配的存储空间中的对象 Original: destructs an object in allocated storage The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (公共成员函数) | |
[编辑] 非成员函数
| 比较两个分配器的实例 Original: compares two allocator instances The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (公共成员函数) | |
[编辑] 另请参阅
| (C++11) |
提供分配器类型的信息 Original: provides information about allocator types The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (类模板) |
| (C++11) |
实现多级的多级容器分配器 Original: implements multi-level allocator for multi-level containers The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (类模板) |
| (C++11) |
检查如果指定的类型支持使用分配器建设的 Original: checks if the specified type supports uses-allocator construction The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (类模板) |