diff --git a/libutils/include/utils/String16.h b/libutils/include/utils/String16.h index 013705b0e..1a4b47eef 100644 --- a/libutils/include/utils/String16.h +++ b/libutils/include/utils/String16.h @@ -187,7 +187,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 d0ad31464..0bcb716af 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 @@ -232,6 +233,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.