TBB 并发哈希映射模板参数

TBB concurrent hash map template arguments

本文关键字:参数 映射 并发 哈希 TBB      更新时间:2023-10-16

我正在尝试使用 TBB concurrent_hash_map容器。在这个例子之后,表明我需要 3 个类型参数(模板参数)、键和值类型以及特征类型 HashCompare。在此链接中,它说HashCompare具有基本类型的默认值。

但是,当尝试以两种方式(2 或 3 个模板参数)中的任何一种使用它时,我收到有关"模板参数太少,预期为 4"的错误 - 实际上,在挖掘代码时,我能找到的头文件中concurrent_hash_map的唯一定义有四个参数:

class concurrent_hash_map<Key,T,HashCompare,Allocator>

我错过了什么,这个例子已经过时了吗?

在某处还有另一个声明,最后两个参数具有默认值。 确保包含必要的头文件:

#include <tbb/concurrent_hash_map.h>

在我的TBB版本中,该文件具有:

template<typename Key, typename T, typename HashCompare = tbb_hash_compare<Key>, typename A = tbb_allocator<std::pair<Key, T> > >
class concurrent_hash_map;