简体   繁体   English

我可以在cplusplus的/usr/include/c++/4.7/ext/bitmap_allocator.h中使用bitmap_allocator吗?

[英]Can I use the bitmap_allocator in /usr/include/c++/4.7/ext/bitmap_allocator.h in cplusplus?

I'm a newbie on cplusplus, and thanks for answering my questions. 我是cplusplus的新手,感谢您回答我的问题。

I'm now trying to find some memory pool allocators other than std::allocator, and I've found that there're some allocators in ../version/ext/ folder. 我现在正在尝试查找除std :: allocator以外的一些内存池分配器,并且我发现../version/ext/文件夹中有一些分配器。 (I'm in Linux and I don't know about windows. And I'm using gnu compiler g++-4.7) (我在Linux中,对Windows不了解。我正在使用gnu编译器g ++-4.7)

I quite found some explanation on GNU: http://gcc.gnu.org/onlinedocs/libstdc++/manual/bk01pt04ch11.html But if I write __gnu_cxx::bitmap_allocator, there'll still be a comile error. 我已经在GNU上找到了一些解释: http ://gcc.gnu.org/onlinedocs/libstdc++/manual/bk01pt04ch11.html但如果我写__gnu_cxx :: bitmap_allocator,仍然会出现编译错误。

It's my own fault... %>_<%. 这是我自己的错...%> _ <%。 A very silly fault = =. 一个非常愚蠢的错误= =。

I did not include the file... 我没有包含文件...

for those who want to know how to use this, code provided as following: 对于那些想知道如何使用它的人,提供的代码如下:

#include <iostream>
#include <vector>
#include <ext/bitmap_allocator.h>

int main()
{
    __gnu_cxx::bitmap_allocator<int> bit_alloc;
    std::vector<int, __gnu_cxx::bitmap_allocator<int> > v(bit_alloc);
    for(int i = 0; i < 10; ++i)
        v.push_back(i);
    for(auto i : v)
        std::cout << i << ' ';
    std::cout << std::endl;

    return 0;
}//main

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

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