According to documentation tbb::concurrent_hash_map
takes argument only via const&
which triggers copy of unique_ptr
:
bool insert( const value_type& value );
As workaround you may use std::shared_ptr
or store unique_ptr
s in stand-alone vector:
std::vector<std::unique_ptr<V>> ptrs;
and store raw pointers in concurrent_hash_map
. Though, that may be not acceptable for your use cases (like frequent deletions).
Another possibility is to use std::auto_ptr
or something similar. But that is dangerous - right copy should arrive into bucket, so you have to test it.