Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(255)

Unified Diff: mojo/public/cpp/bindings/map_traits_wtf_hash_map.h

Issue 2339413004: Allow Mojo structs as map keys (Closed)
Patch Set: Remove left-over import Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: mojo/public/cpp/bindings/map_traits_wtf_hash_map.h
diff --git a/mojo/public/cpp/bindings/map_traits_wtf_hash_map.h b/mojo/public/cpp/bindings/map_traits_wtf_hash_map.h
index 439220130e85874fd98379d7a1bc9b9fce494b0f..88ee3bf5c8b9d65d85449a027e5aecf001a0fe78 100644
--- a/mojo/public/cpp/bindings/map_traits_wtf_hash_map.h
+++ b/mojo/public/cpp/bindings/map_traits_wtf_hash_map.h
@@ -46,12 +46,13 @@ struct MapTraits<WTF::HashMap<K, V>> {
static V& GetValue(Iterator& iterator) { return iterator->value; }
static const V& GetValue(ConstIterator& iterator) { return iterator->value; }
- static bool Insert(WTF::HashMap<K, V>& input, const K& key, V&& value) {
+ template <typename IK, typename IV>
+ static bool Insert(WTF::HashMap<K, V>& input, IK&& key, IV&& value) {
if (!WTF::HashMap<K, V>::isValidKey(key)) {
LOG(ERROR) << "The key value is disallowed by WTF::HashMap: " << key;
return false;
}
- input.add(key, std::forward<V>(value));
+ input.add(std::forward<IK>(key), std::forward<IV>(value));
return true;
}
static bool Insert(WTF::HashMap<K, V>& input, const K& key, const V& value) {
yzshen1 2016/09/20 23:44:40 Do we still need this method?
tibell 2016/09/21 07:10:53 Done.

Powered by Google App Engine
This is Rietveld 408576698