老得查代码写,这里记录一下:
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);
本文详细介绍了如何使用 C++ 中 __gnu_cxx 的 hash_map,并给出了具体的实例代码。展示了如何定义和初始化一个全局角色指针分配器及 Role 类型的 hash_map。
4943

被折叠的 条评论
为什么被折叠?



