繁体   English   中英

符合C ++ STL的分配器

[英]C++ STL-conforming Allocators

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

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

~$ find /usr/include/c++/4.2.1/ -name "*allocator*"
/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库 (以及本书 )中检出小对象分配器。

Microsoft Visual C ++标准库实现为基于节点的容器提供了几个专有的分配器 (至少在即将发布的Visual Studio 2010中)。

您需要一个适合您特定需求的分配器。 STL通用分配器最适合多种情况,如果您想要一个新的分配器,则需要分析并了解您的特定要求。 您必须更具体地说明将这些对象放入哪个容器。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM