记录一下 __gnu_cxx::hash_map传一个新allocator的写法

老得查代码写,这里记录一下:

hash_map(size_type __n, const hasher& __hf, 
    const key_equal& __eql, const allocator_type& __a = allocator_type())
 

// 全局的角色指针Allocator
__gnu_cxx::__pool_alloc<Role*> g_rolePtrAlloc; 


typedef __gnu_cxx::hash_map<
     uint32_t, 
     Role*, 
     __gnu_cxx::hash<uint32_t>, 
     std::equal_to<uint32_t>, 
     __gnu_cxx::__pool_alloc<Role*> > Roles;
Roles roles(5000, __gnu_cxx::hash<uint32_t>(), 
    std::equal_to<uint32_t>(), g_rolePtrAlloc);


posted on 2012-02-23 16:30  daemonh  阅读(346)  评论(0编辑  收藏  举报

导航