- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
A quick question:
When using tbb concurrent hash map, does memory used by key during insert() requires to be preserved? I guess so because tbb may require it for equal() but like to get definite answer. For example,
void add(const char *string, uint32_t type, void *data) {
MyKey key;
key.string = string;
key.type = type;
map->insert(key, data);
}
Sinc key is local, it will be destroyed once function returns. Is this okay or does TBB requires that the key instance to be preserved for the lifetime of object in the map
Thanks!
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Yumo,
In accordance with documentation, value_type contains the Key type by value:
typedef std::pair<const Key,T> value_type;
I.e. the Key values are copied inside the container and should not be preserved after insertion.
Regards,
Alex
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page