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

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

Issue 2511883006: Mojo C++ bindings: switch services/ui/public/interfaces mojom target to use STL types. (Closed)
Patch Set: . Created 4 years, 1 month 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
« no previous file with comments | « no previous file | services/ui/public/cpp/tests/test_window_tree.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/public/cpp/bindings/map.h
diff --git a/mojo/public/cpp/bindings/map.h b/mojo/public/cpp/bindings/map.h
index d4c79525ee83c47ce9749fbab68bf9781c4dab3e..ec40df34270b41577ff13ca454841b7b4165b430 100644
--- a/mojo/public/cpp/bindings/map.h
+++ b/mojo/public/cpp/bindings/map.h
@@ -299,6 +299,32 @@ struct TypeConverter<std::map<STLKey, STLValue>, Map<MojoKey, MojoValue>> {
}
};
+// TODO(yzshen): These conversion functions should be removed and callsites
+// should be revisited and changed to use the same map type.
+template <typename Key, typename Value>
+std::unordered_map<Key, Value> MapToUnorderedMap(
+ const std::map<Key, Value>& input) {
+ return std::unordered_map<Key, Value>(input.begin(), input.end());
+}
+
+template <typename Key, typename Value>
+std::unordered_map<Key, Value> MapToUnorderedMap(std::map<Key, Value>&& input) {
+ return std::unordered_map<Key, Value>(std::make_move_iterator(input.begin()),
+ std::make_move_iterator(input.end()));
+}
+
+template <typename Key, typename Value>
+std::map<Key, Value> UnorderedMapToMap(
+ const std::unordered_map<Key, Value>& input) {
+ return std::map<Key, Value>(input.begin(), input.end());
+}
+
+template <typename Key, typename Value>
+std::map<Key, Value> UnorderedMapToMap(std::unordered_map<Key, Value>&& input) {
+ return std::map<Key, Value>(std::make_move_iterator(input.begin()),
+ std::make_move_iterator(input.end()));
+}
+
} // namespace mojo
#endif // MOJO_PUBLIC_CPP_BINDINGS_MAP_H_
« no previous file with comments | « no previous file | services/ui/public/cpp/tests/test_window_tree.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698