0

私はcplusplusの初心者です、そして私の質問に答えてくれてありがとう。

std :: allocator以外のメモリプールアロケータを見つけようとしていますが、.. / version /ext/フォルダにいくつかのアロケータがあることがわかりました。(私はLinuxを使用していて、Windowsについては知りません。そしてgnuコンパイラg ++-4.7を使用しています)

GNUに関する説明をかなり見つけました:http: //gcc.gnu.org/onlinedocs/libstdc++/manual/bk01pt04ch11.html しかし、__ gnu_cxx :: bitmap_allocatorと書くと、コマイルエラーが発生します。

4

1 に答える 1

0

それは私自身のせいです...%> _ <%。非常にばかげた障害==。

私はファイルを含めませんでした...

これを使用する方法を知りたい人のために、次のように提供されるコード:

#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
于 2012-12-01T08:04:00.850 に答える