diff --git a/include/grpc++/support/string_ref.h b/include/grpc++/support/string_ref.h index 348c42cbbaa273c5e0c7bc3728a44b3f61fca47b..fd2b3ad8e7b6ed4c326c68d97ff763c9b2fddcb8 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 d9c9019da89478eee9e353b21d81c032de49e959..eb54f65e3ac1b9e71d66e3a9c4669b701097f794 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