SGI特殊空间配置器:std::alloc
new 运算符含有两个阶段的过程:(1):申请内存(内存分配) (2)调用构造函数初始化 同理delete也有两个过程。
为了精密分工STL allocator决定将两个阶段操作区分开来: 内存配置与释放alloc::allocate()与alloc::deallocate()完成
对象构造过程由::construct 和::deconstruct(destroy)完成 分别对应<memory>下的<stl_alloc.h>和<stl_construct.h>
memory : 分为
1.<stl_construct.h> 包含全局函数:construct/destroy
2.<stl_alloc.h> 包含一二级配置器 ,命名为 alloc
3.<stl_uninitialized.h> 包含几个全局函数用来填充Fill和复制Copy大块内存数据 :
- un_initialized_copy
- un_initialized_fill
- un_initialized_fill_n
Construct:
首先讲一下stl_construct.h中的construct与destroy函数。
template<class T1,class T2>
inline void construct(T1 *p,const T2 &value){