我正在使用英特尔 TBB Concurrent Hash Map tbb::hash_map<std::string, std::reference_wrapper<Clusters>>
我想使用
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/