From b1d3161b7b3d107505b3aab51a2d2728f4699eb5 Mon Sep 17 00:00:00 2001 From: Steven Moreland Date: Tue, 25 Feb 2020 17:59:34 -0800 Subject: [PATCH] String8: operator<< For parity with String16. Bug: N/A Test: N/A Change-Id: I2d7d207138c96146814da31cf27a49cc310e5362 --- libutils/include/utils/String16.h | 2 +- libutils/include/utils/String8.h | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/libutils/include/utils/String16.h b/libutils/include/utils/String16.h index c0e3f1eba..e39cdcc46 100644 --- a/libutils/include/utils/String16.h +++ b/libutils/include/utils/String16.h @@ -197,7 +197,7 @@ public: ANDROID_TRIVIAL_MOVE_TRAIT(String16) static inline std::ostream& operator<<(std::ostream& os, const String16& str) { - os << String8(str).c_str(); + os << String8(str); return os; } diff --git a/libutils/include/utils/String8.h b/libutils/include/utils/String8.h index 0ddcbb2be..b9bd90378 100644 --- a/libutils/include/utils/String8.h +++ b/libutils/include/utils/String8.h @@ -17,7 +17,8 @@ #ifndef ANDROID_STRING8_H #define ANDROID_STRING8_H -#include // for std::string +#include +#include #include #include @@ -241,6 +242,11 @@ private: // require any change to the underlying SharedBuffer contents or reference count. ANDROID_TRIVIAL_MOVE_TRAIT(String8) +static inline std::ostream& operator<<(std::ostream& os, const String8& str) { + os << str.c_str(); + return os; +} + // --------------------------------------------------------------------------- // No user servicable parts below.