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

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

Issue 2339413004: Allow Mojo structs as map keys (Closed)
Patch Set: Fix merge problem in BUILD.gn file 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/string.h
diff --git a/mojo/public/cpp/bindings/string.h b/mojo/public/cpp/bindings/string.h
index 7cfd713f66959bbaac1e17d92127039d11bf31c7..892cc1c29ffe885ec7122603bf11dbd6e269eba8 100644
--- a/mojo/public/cpp/bindings/string.h
+++ b/mojo/public/cpp/bindings/string.h
@@ -7,10 +7,12 @@
#include <stddef.h>
+#include <functional>
#include <string>
#include "base/logging.h"
#include "mojo/public/cpp/bindings/lib/array_internal.h"
+#include "mojo/public/cpp/bindings/lib/hash_util.h"
#include "mojo/public/cpp/bindings/type_converter.h"
namespace mojo {
@@ -193,4 +195,15 @@ struct TypeConverter<String, const char*> {
} // namespace mojo
+namespace std {
+
+template <>
+struct hash<mojo::String> {
+ size_t operator()(const mojo::String& value) const {
+ return value.is_null() ? 0 : hash<std::string>()(value.get());
+ }
+};
+
+} // namespace std
+
#endif // MOJO_PUBLIC_CPP_BINDINGS_STRING_H_

Powered by Google App Engine
This is Rietveld 408576698