From 47ec9a40ade6cf5b205b035b1142e0cc539c4f70 Mon Sep 17 00:00:00 2001
From: Craig Tiller <ctiller@google.com>
Date: Wed, 26 Aug 2015 09:47:51 -0700
Subject: [PATCH] Add ostream support for string_ref

---
 include/grpc++/support/string_ref.h | 3 +++
 src/cpp/util/string_ref.cc          | 4 ++++
 2 files changed, 7 insertions(+)

diff --git a/include/grpc++/support/string_ref.h b/include/grpc++/support/string_ref.h
index 348c42cbba..fd2b3ad8e7 100644
--- a/include/grpc++/support/string_ref.h
+++ b/include/grpc++/support/string_ref.h
@@ -35,6 +35,7 @@
 #define GRPCXX_STRING_REF_H
 
 #include <iterator>
+#include <iosfwd>
 
 #include <grpc++/support/config.h>
 
@@ -110,6 +111,8 @@ bool operator>(string_ref x, string_ref y);
 bool operator<=(string_ref x, string_ref y);
 bool operator>=(string_ref x, string_ref y);
 
+std::ostream& operator<<(std::ostream& stream, const string_ref& string);
+
 }  // namespace grpc
 
 #endif  // GRPCXX_STRING_REF_H
diff --git a/src/cpp/util/string_ref.cc b/src/cpp/util/string_ref.cc
index d9c9019da8..eb54f65e3a 100644
--- a/src/cpp/util/string_ref.cc
+++ b/src/cpp/util/string_ref.cc
@@ -108,4 +108,8 @@ bool operator>=(string_ref x, string_ref y) {
   return x.compare(y) >= 0;
 }
 
+std::ostream& operator<<(std::ostream& out, const string_ref& string) {
+  return out << grpc::string(string.begin(), string.end());
+}
+
 }  // namespace grpc
-- 
GitLab