OSDN Git Service

libbinder: Remove templated binder::Status stream operator.
authorRalph Nathan <ralphnathan@google.com>
Wed, 13 Apr 2016 19:42:06 +0000 (12:42 -0700)
committerRalph Nathan <ralphnathan@google.com>
Wed, 13 Apr 2016 19:46:25 +0000 (12:46 -0700)
The templated binder::Status stream operator doesn't work with gmock
because of ambiguous operator overloading. Limiting the stream operator
to just std::stringstream allows it to be used with gmock.

BUG=28171901
TEST=Compiles with gmock and CameraBinderTests

Change-Id: Ia674b68cbff4911b3f5cc3d8ee57d04a1d6cf6bf

include/binder/Status.h
libs/binder/Status.cpp

index ce947fa..7253af8 100644 (file)
@@ -18,6 +18,7 @@
 #define ANDROID_BINDER_STATUS_H
 
 #include <cstdint>
+#include <sstream>
 
 #include <binder/Parcel.h>
 #include <utils/String8.h>
@@ -142,11 +143,7 @@ private:
 };  // class Status
 
 // For gtest output logging
-template<typename T>
-T& operator<< (T& stream, const Status& s) {
-    stream << s.toString8().string();
-    return stream;
-}
+std::stringstream& operator<< (std::stringstream& stream, const Status& s);
 
 }  // namespace binder
 }  // namespace android
index d3520d6..5ae6db2 100644 (file)
@@ -158,5 +158,10 @@ String8 Status::toString8() const {
     return ret;
 }
 
+std::stringstream& operator<< (std::stringstream& stream, const Status& s) {
+    stream << s.toString8().string();
+    return stream;
+}
+
 }  // namespace binder
 }  // namespace android