定义于头文件 <memory>
template< class T >struct allocator; (1)
template<>struct allocator<void>; (2) (C++17 中弃用) (C++20 中移除)
std::allocator 类模板是所有标准库容器所用的默认分配器 (Allocator) ,若不提供用户指定的分配器。默认分配器无状态,即任何给定的 allocator 实例可交换、比较相等,且能解分配同一 allocator 类型的任何其他实例所分配的内存。
| 对 void 的显式特化缺少成员 typedef |
(C++20 前) |
| 所有自定义分配器必须也无状态。 | (C++11 前) |
| 自定义分配器可以含有状态。每个容器或其他具分配器对象存储一个提供的分配器实例,并通过 std::allocator_traits 控制分配器替换。 | (C++11 起) |
| 默认分配器满足分配器完整性要求。 | (C++17 起) |
构造函数
std::allocator<T>::allocator
| allocator() throw(); |
(1) | (C++11 前) |
| allocator() noexcept; |
(C++11 起) (C++20 前) |
|
| constexpr allocator() noexcept; |
(C++20 起) | |
| allocator( const allocator& other ) throw(); |
(2) | (C++11 前) |
| allocator( const allocator& other ) noexcept; |
(C++11 起) (C++20 前) |
|
| constexpr allocator( const allocator& other ) noexcept; |
(C++20 起) | |
| template< class U > |
(3) | (C++11 前) |
| template< class U > |
(C++11 起) (C++20 前) |
|
| template< class U > |
(C++20 起) |
构造默认分配器。因为默认分配器是无状态的,故构造函数无可见效应。
参数
| other | - | 用以构造的另一 allocator |
析构函数
std::allocator<T>::~allocator
| < |

&spm=1001.2101.3001.5002&articleId=126797798&d=1&t=3&u=3e55627120734e559c2081ffbb8a0d38)
973

被折叠的 条评论
为什么被折叠?



