-
Notifications
You must be signed in to change notification settings - Fork 80
Open
Description
I want to write a concurrent cache where I can lookup multiple items at once:
template <class K, class V>
std::vector<std::optional<V>> lookup(const concurrent_flat_map<K, V>& map, const std::vector<K>& keys){
std::vector<std::optional<V>> result;
map.cvisit(keys.begin(), keys.end(), [&](const auto& x){
// PROBLEM: how to get 'i'??
result[i] = x->second;
});
return result;
}
I can't find a way to write this with the current API. I would like a new function that traverses an additional iterator in the same order:
template <class K, class V>
std::vector<std::optional<V>> lookup(const concurrent_flat_map<K, V>& map, const std::vector<K>& keys){
std::vector<std::optional<V>> result;
map.cvisit(keys.begin(), keys.end(), result.begin(), [&](const auto& x, auto& it){
*it = x->second;
});
return result;
}
Metadata
Metadata
Assignees
Labels
No labels