gpt4 book ai didi

c++ - TBB 并发 HashMap 模板参数

转载 作者:行者123 更新时间:2023-11-30 03:42:18 33 4
gpt4 key购买 nike

我正在尝试使用 TBB concurrent_hash_map 容器。按照这个 example ,表明我需要 3 个类型参数(模板参数),键和值类型以及特征类型 HashCompare。在 this链接,它表示 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;

关于c++ - TBB 并发 HashMap 模板参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36889858/

33 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com