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

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

Issue 2339413004: Allow Mojo structs as map keys (Closed)
Patch Set: Revert no-longer-needed changes to clone_equals_util.h 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..edde377607e5807c2588b2d53b1d775580853776 100644
--- a/mojo/public/cpp/bindings/map_traits_wtf_hash_map.h
+++ b/mojo/public/cpp/bindings/map_traits_wtf_hash_map.h
@@ -46,20 +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;
+ LOG(ERROR) << "The key value is disallowed by WTF::HashMap";
return false;
}
- input.add(key, std::forward<V>(value));
- return true;
- }
- static bool Insert(WTF::HashMap<K, V>& input, const K& key, const V& value) {
- if (!WTF::HashMap<K, V>::isValidKey(key)) {
- LOG(ERROR) << "The key value is disallowed by WTF::HashMap: " << key;
- return false;
- }
- input.add(key, value);
+ input.add(std::forward<IK>(key), std::forward<IV>(value));
return true;
}

Powered by Google App Engine
This is Rietveld 408576698