什么是使用boost ::池分配器用的boost :: unordered_map语法?
-
21-08-2019 - |
题
我只是用升压::池实验,看看它的东西,我有工作更快的分配,但我无法弄清楚如何使用的boost :: unordered_map使用它:
下面是一个代码段:
unordered_map<int,int,boost::hash<int>, fast_pool_allocator<int>> theMap;
theMap[1] = 2;
下面被编译错误我得到:
错误3错误C2064:术语不计算为服用2个参数C中的函数:\程序文件(x86)\升压\ boost_1_38 \升压\无序\详细\ hash_table_impl.hpp 2048
如果我注释掉使用的地图,例如“theMap [1] = 2”,则编译错误消失。
解决方案
它看起来像你缺少一个模板参数
template<typename Key, typename Mapped, typename Hash = boost::hash<Key>,
typename Pred = std::equal_to<Key>,
typename Alloc = std::allocator<std::pair<Key const, Mapped> > >
第四个参数是用于比较谓词,第五个是分配器。
unordered_map<int, int, boost::hash<int>,
std::equal_to<int>, fast_pool_allocator<int> > theMap;
此外,但可能不是你的问题的原因,你需要分开的两个“>”在模板实例化的结尾。
不隶属于 StackOverflow