MSTL 1.4.0
A Modern C++ Library with extended functionality, web components, and utility libraries
载入中...
搜索中...
未找到
standard_allocator< T > 模板类 参考

标准分配器类 更多...

#include <standard_allocator.hpp>

类 standard_allocator< T > 继承关系图:
[图例]

struct  rebind
 重新绑定模板 更多...

Public 类型

using value_type = T
 元素类型
using pointer = T*
 指针类型
using size_type = _INNER alloc_size_t
 大小类型

Public 成员函数

MSTL_CONSTEXPR20 standard_allocator () noexcept=default
 默认构造函数
template<typename U>
MSTL_CONSTEXPR20 standard_allocator (const standard_allocator< U > &) noexcept
 从其他分配器类型转换构造
MSTL_CONSTEXPR20 ~standard_allocator () noexcept=default
 析构函数
MSTL_CONSTEXPR20 standard_allocatoroperator= (const standard_allocator &) noexcept=default
 赋值运算符

静态 Public 成员函数

MSTL_ALLOC_NODISCARD MSTL_CONSTEXPR20 static MSTL_ALLOC_OPTIMIZE pointer allocate (const size_type n)
 分配指定数量的元素内存
MSTL_ALLOC_NODISCARD MSTL_CONSTEXPR20 static MSTL_ALLOC_OPTIMIZE pointer allocate ()
 分配单个元素内存
static MSTL_CONSTEXPR20 void deallocate (pointer p, const size_type n) noexcept
 释放先前分配的内存
static MSTL_CONSTEXPR20 void deallocate (pointer p) noexcept
 释放单个元素内存

详细描述

template<typename T>
class standard_allocator< T >

标准分配器类

模板参数
T要分配的元素类型

提供类型安全的内存分配和释放,支持对齐优化。

在文件 standard_allocator.hpp315 行定义.

构造及析构函数说明

◆ standard_allocator()

template<typename T>
template<typename U>
MSTL_CONSTEXPR20 standard_allocator< T >::standard_allocator ( const standard_allocator< U > & )
inlinenoexcept

从其他分配器类型转换构造

模板参数
U源分配器元素类型

在文件 standard_allocator.hpp350 行定义.

成员函数说明

◆ allocate() [1/2]

template<typename T>
MSTL_ALLOC_NODISCARD MSTL_CONSTEXPR20 static MSTL_ALLOC_OPTIMIZE pointer standard_allocator< T >::allocate ( )
inlinestatic

分配单个元素内存

返回
指向分配内存的指针
异常
allocate_exception如果内存分配失败

在文件 standard_allocator.hpp382 行定义.

被这些函数引用 standard_allocator< U >::allocate().

◆ allocate() [2/2]

template<typename T>
MSTL_ALLOC_NODISCARD MSTL_CONSTEXPR20 static MSTL_ALLOC_OPTIMIZE pointer standard_allocator< T >::allocate ( const size_type n)
inlinestatic

分配指定数量的元素内存

参数
n要分配的元素数量
返回
指向分配内存的指针
异常
allocate_exception如果内存分配失败

分配 n 个 T 类型的连续内存空间。

在文件 standard_allocator.hpp364 行定义.

◆ deallocate() [1/2]

template<typename T>
MSTL_CONSTEXPR20 void standard_allocator< T >::deallocate ( pointer p)
inlinestaticnoexcept

释放单个元素内存

参数
p要释放的内存指针

在文件 standard_allocator.hpp401 行定义.

◆ deallocate() [2/2]

template<typename T>
MSTL_CONSTEXPR20 void standard_allocator< T >::deallocate ( pointer p,
const size_type n )
inlinestaticnoexcept

释放先前分配的内存

参数
p要释放的内存指针
n先前分配的元素数量
注解
p 必须为 nullptr 或先前由 allocate() 返回的指针

在文件 standard_allocator.hpp392 行定义.

被这些函数引用 standard_allocator< U >::deallocate().


该类的文档由以下文件生成: