gpt4 book ai didi

c++ - 如何搜索包含reference_wrapper 的hash_map?

转载 作者:太空狗 更新时间:2023-10-29 23:06:12 26 4
gpt4 key购买 nike

我正在使用英特尔 TBB Concurrent Hash Map tbb::hash_map<std::string, std::reference_wrapper<Clusters>>我想使用

搜索这个 hash_map
tbb::concurrent_hash_map<std::string, std::reference_wrapper<Clusters>>::accessor a;
if(table.find(a, operation.get().GetKey()))
{
a->second.get().AddOperation(operation);
}

但它给出了 error: no matching function for call to ‘std::reference_wrapper<Clusters>::reference_wrapper() .所以问题是reference_wrapper没有默认构造函数 find需要。有什么办法可以避免这个吗?

最佳答案

这似乎是 find() 或其文档的实现中的错误。要么它需要映射类型为 DefaultConstructible,但它不应该,或者它没有记录它需要这个。

我认为这不是您可以解决的问题。作为解决方法,您可以在 map 中存储指针而不是引用包装器。

关于c++ - 如何搜索包含reference_wrapper 的hash_map?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16663056/

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