开发者

Overload Allocator and deallocator of stl::map in c++

Is it possible to overload allocator/deallocator of stl::map in c++? If yes then how? An开发者_Python百科y help would be appreciated.


Yes, you can specify it as a template argument:

map<Key, Data, Compare, Alloc>

See http://www.sgi.com/tech/stl/Map.html and http://www.sgi.com/tech/stl/Allocators.html


Yes, it is possible to do so. If you'll notice, all STL containers are parameterized over a template argument indicating where memory should be obtained from. This is typically done with the STD::allocator type, but you can provide your own custom allocator as well. This is not easy to do because of various design limitations in the allocator requirements, but there are several good links out there. Here's one:

http://www.roguewave.com/Portals/0/products/sourcepro/docs/11.1/html/toolsug/11-6.html

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜