You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by mz...@apache.org on 2019/03/18 20:54:59 UTC

[mesos] 12/16: Added `<<` operator to `protobuf::Map`.

This is an automated email from the ASF dual-hosted git repository.

mzhu pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mesos.git

commit 4fd5978796cd30d08867534c478deaeac24b8664
Author: Meng Zhu <mz...@mesosphere.io>
AuthorDate: Thu Mar 7 22:58:56 2019 -0800

    Added `<<` operator to `protobuf::Map`.
    
    Review: https://reviews.apache.org/r/70160
---
 include/mesos/type_utils.hpp | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/include/mesos/type_utils.hpp b/include/mesos/type_utils.hpp
index 630f21f..acf5ba8 100644
--- a/include/mesos/type_utils.hpp
+++ b/include/mesos/type_utils.hpp
@@ -530,6 +530,23 @@ inline bool operator!=(
 }
 
 
+template <typename Key, typename Value>
+inline std::ostream& operator<<(
+  std::ostream& stream, const Map<Key, Value>& map)
+{
+  stream << "{ ";
+  for (auto it = map.cbegin(); it != map.end(); ++it) {
+    if (it != map.cbegin()) {
+      stream << ", ";
+    }
+    stream << it->first << ": " << it->second;
+  }
+  stream << " }";
+
+  return stream;
+}
+
+
 template <typename T>
 inline std::ostream& operator<<(
     std::ostream& stream,