2013-05-21 24 views
3

我使用英特爾TBB Concurrent Hash Maptbb::hash_map<std::string, std::reference_wrapper<Clusters>>,我想搜索使用如何搜索包含reference_wrapper的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); 
} 

此的hash_map但它給error: no matching function for call to ‘std::reference_wrapper<Clusters>::reference_wrapper()。所以問題是reference_wrapper沒有默認的構造函數,它需要find。有什麼辦法可以繞過這個嗎?

+2

沒有'std :: hash_map','std :: unordered_map'沒有名爲'accessor'的成員。這些來自某個圖書館嗎? – Angew

+0

對不起,我認爲std hash_map具有相同的成員。它來自英特爾TBB並行哈希映射 – user

+0

是從find()報告的錯誤嗎?它似乎並不需要這樣的構造函數。你可以顯示'GetKey()'的實現嗎? – Angew

回答

1

這似乎是在執行find()或其文檔中的錯誤。當它不應該時它需要映射類型爲DefaultConstructible,或者它不記錄它需要這個。

我不認爲這是你可以解決的問題。作爲一種解決方法,您可以將指針存儲在映射中而不是引用包裝器中。