C++標(biāo)準(zhǔn)的內(nèi)存配置和釋放動(dòng)作:
class test{.....};
test* pt =new test;
//(1) 呼叫::opearator new 配置內(nèi)存
//(2) 呼叫test::test()構(gòu)建對(duì)象
delete pt;
//(1)呼叫test::~test()解構(gòu)對(duì)象
//(2) 呼叫::opearator delete 釋放內(nèi)存
在sgi STL中:
內(nèi)存配置--> alloc::allocator()
內(nèi)存釋放--> alloc::deallocator()
以上定義在alloc.h中
對(duì)象構(gòu)建--> ::construct()
對(duì)象解構(gòu)--> ::destroy()
以上定義在construct.h中
image.png
關(guān)于constrcut的實(shí)現(xiàn)點(diǎn)這里