符合C++ STL的分配器

mya*_*hya 5 c++ stl allocator

在处理小对象时,可以使用哪些分配器与STL一起使用.我已经尝试过使用Boost的池分配器,但没有性能提升(实际上,在某些情况下会有相当大的降级).

Nik*_*sov 3

您没有说您使用什么编译器,但它可能带有一堆预构建的分配器。这是在装有gcc 4.2.1的 Mac 上:

~$ 查找 /usr/include/c++/4.2.1/ -name "*分配器*"
/usr/include/c++/4.2.1/bits/allocator.h
/usr/include/c++/4.2.1/ext/array_allocator.h
/usr/include/c++/4.2.1/ext/bitmap_allocator.h
/usr/include/c++/4.2.1/ext/debug_allocator.h
/usr/include/c++/4.2.1/ext/malloc_allocator.h
/usr/include/c++/4.2.1/ext/mt_allocator.h
/usr/include/c++/4.2.1/ext/new_allocator.h
/usr/include/c++/4.2.1/ext/pool_allocator.h
/usr/include/c++/4.2.1/ext/throw_allocator.h

这里还有一个BitMagic项目页面的链接,其中讨论了如何构建您自己的项目。另请查看Loki 库(以及本书)中的小对象分配器。