内容文案gygwin-包括hstl source sgi defallocSTL SORCE SGI DEFALOC.pdfVIP

  • 0
  • 0
  • 约3.52千字
  • 约 3页
  • 2025-07-26 发布于北京
  • 举报

内容文案gygwin-包括hstl source sgi defallocSTL SORCE SGI DEFALOC.pdf

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*

文档评论(0)

1亿VIP精品文档

相关文档