- 0
- 0
- 约3.52千字
- 约 3页
- 2025-07-26 发布于北京
- 举报
G++2.91.57,cygnus\cygwin-b20\include\g++\defalloc.h完整列表
//InclusionofthisfileisDEPRECATED.ThisistheoriginalHP
//defaultallocator.Itisprovidedonlyforbackwardcompatibility.
//
//DONOTUSETHISFILEunlessyouhaveanoldcontainerimplementation
//thatrequiresanallocatorwiththeHP-styleinterface.SGISTL
//usesadifferentallocatorinterface.SGI-styleallocatorsarenot
//parametrizedwithrespecttotheobjecttype;theytrafficinvoid*
//pointers.ThisfileisnotincludedbyanyotherSGISTLheader.
#ifndefDEFALLOC_H
#defineDEFALLOC_H
#includenew.h
#includestddef.h
#includestdlib.h
#includelimits.h
#includeiostream.h
#includealgobase.h
templateclassT
inlineT*allocate(ptrdiff_tsize,T*){
set_new_handler(0);
T*tmp=(T*)(::operatornew((size_t)(size*sizeof(T))));
if(tmp0){
cerroutofmemoryendl;
exit(1);
}
returntmp;
}
templateclassT
inlinevoiddeallocate(T*buffer){
::operatordelete(buffer);
}
templateclassT
classallocator{
public:
typedefTvalue_type;
typedefT*pointer;
typedefconstT*const_pointer;
typedefTreference;
typedefconstTconst_reference;
typedefsize_tsize_type;
typedefptrdiff_tdifference_type;
pointerallocate(size_typen){
return::allocate((difference_type)n,(pointer)0);
}
voiddeallocate(pointerp){::deallocate(p);}
pointeraddress(referencex){return(pointer)x;}
const_pointerconst_address(const_referencex){
return(const_pointer)x;
}
size_typeinit_page_size(){
returnmax(size_type(1),size_type(4096/sizeof(T)));
}
size_typemax_size()const{
returnmax(size_type(1),size_type(UINT_MAX/sizeof(T)));
}
};
classallocatorvoid{
public:
typedefvoid*
您可能关注的文档
最近下载
- 第十章血脂及浆脂蛋白检验.doc VIP
- GB 50207-2012 屋面工程质量验收规范.docx VIP
- 高铁乘务人员形体训练全套教学课件.pptx
- 六年级上册道德与法治知识点.docx VIP
- 2026年课件-《成人患者医用粘胶相关性皮肤损伤的预防及护理》团体标准解读2026-新版.pdf
- 2017-2018年度零售业消费者满意度调查报告.pdf VIP
- 〖初中数学〗整式的乘法 课件 2024--2025学年北师大版七年级数学下册.pptx VIP
- 深度解析(2026)《SYT 5679-2017钻井液用降滤失剂 褐煤树脂 SPNH》.pptx VIP
- 12J201 平屋面建筑构造图集.docx VIP
- 社会调查研究计划书.docx VIP
原创力文档

文档评论(0)