MSTL 1.4.0
A Modern C++ Library with extended functionality, web components, and utility libraries
载入中...
搜索中...
未找到
allocator_traits< Alloc > 模板结构体 参考

分配器特性模板 更多...

#include <allocator_traits.hpp>

Public 类型

using const_pointer = typename real_ptr<__c_pointer, const value_type>::type
 常量指针类型
using difference_type = typename real_diff<Alloc, pointer>::type
 指针差异类型
using size_type = typename real_size<Alloc, difference_type>::type
 大小类型
template<typename T>
using rebind_alloc = alloc_rebind<Alloc, T>
 重新绑定分配器类型
template<typename T>
using rebind_traits = allocator_traits<rebind_alloc<T>>
 重新绑定分配器特性类型

静态 Public 成员函数

static MSTL_NODISCARD MSTL_CONSTEXPR20 pointer allocate (Alloc &alloc, size_type n)
 分配内存
static MSTL_CONSTEXPR20 void deallocate (Alloc &alloc, pointer ptr, size_type n)
 释放内存
template<typename T, typename... Args>
static MSTL_CONSTEXPR20 void construct (Alloc &alloc, T *ptr, Args &&... args) noexcept(noexcept(allocator_traits::__construct_aux(alloc, ptr, _MSTL forward< Args >(args)...)))
 在已分配内存上构造对象
template<typename T>
static MSTL_CONSTEXPR20 void destroy (Alloc &alloc, T *ptr) noexcept(noexcept(allocator_traits::__destroy_aux(alloc, ptr, 0)))
 销毁对象
static MSTL_CONSTEXPR20 size_type max_size (const Alloc &alloc) noexcept(noexcept(allocator_traits::__max_size_aux(alloc, 0)))
 获取分配器支持的最大大小

详细描述

template<typename Alloc>
struct allocator_traits< Alloc >

分配器特性模板

模板参数
Alloc分配器类型

提供对分配器类型的统一访问接口,即使分配器不提供某些成员类型或函数。

主要功能:

  1. 提取分配器的各种类型特征
  2. 提供分配器操作的统一接口
  3. 为不完整的分配器接口提供默认实现
  4. 支持分配器的重新绑定

在文件 allocator_traits.hpp82 行定义.

成员类型定义说明

◆ rebind_alloc

template<typename Alloc>
template<typename T>
using allocator_traits< Alloc >::rebind_alloc = alloc_rebind<Alloc, T>

重新绑定分配器类型

模板参数
T新的元素类型

在文件 allocator_traits.hpp126 行定义.

◆ rebind_traits

template<typename Alloc>
template<typename T>
using allocator_traits< Alloc >::rebind_traits = allocator_traits<rebind_alloc<T>>

重新绑定分配器特性类型

模板参数
T新的元素类型

在文件 allocator_traits.hpp133 行定义.

成员函数说明

◆ allocate()

template<typename Alloc>
MSTL_NODISCARD MSTL_CONSTEXPR20 pointer allocator_traits< Alloc >::allocate ( Alloc & alloc,
size_type n )
inlinestatic

分配内存

参数
alloc分配器对象
n要分配的元素数量
返回
指向分配内存的指针

在文件 allocator_traits.hpp182 行定义.

被这些函数引用 allocate_guarded() , 以及 allocate_shared().

◆ construct()

template<typename Alloc>
template<typename T, typename... Args>
MSTL_CONSTEXPR20 void allocator_traits< Alloc >::construct ( Alloc & alloc,
T * ptr,
Args &&... args )
inlinestaticnoexcept

在已分配内存上构造对象

模板参数
T要构造的对象类型
Args构造函数参数类型
参数
alloc分配器对象
ptr指向已分配内存的指针
args构造函数参数

在文件 allocator_traits.hpp205 行定义.

被这些函数引用 allocate_shared().

◆ deallocate()

template<typename Alloc>
MSTL_CONSTEXPR20 void allocator_traits< Alloc >::deallocate ( Alloc & alloc,
pointer ptr,
size_type n )
inlinestatic

释放内存

参数
alloc分配器对象
ptr要释放的内存指针
n先前分配的元素数量

在文件 allocator_traits.hpp192 行定义.

被这些函数引用 allocate_shared() , 以及 allocated_ptr< Alloc >::~allocated_ptr().

◆ destroy()

template<typename Alloc>
template<typename T>
MSTL_CONSTEXPR20 void allocator_traits< Alloc >::destroy ( Alloc & alloc,
T * ptr )
inlinestaticnoexcept

销毁对象

模板参数
T要销毁的对象类型
参数
alloc分配器对象
ptr指向要销毁对象的指针

在文件 allocator_traits.hpp217 行定义.

被这些函数引用 allocate_shared().

◆ max_size()

template<typename Alloc>
MSTL_CONSTEXPR20 size_type allocator_traits< Alloc >::max_size ( const Alloc & alloc)
inlinestaticnoexcept

获取分配器支持的最大大小

参数
alloc分配器对象
返回
分配器可以分配的最大元素数量

在文件 allocator_traits.hpp227 行定义.


该结构体的文档由以下文件生成: