summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Steven Moreland <smoreland@google.com> 2023-01-12 01:19:33 +0000
committer Gerrit Code Review <noreply-gerritcodereview@google.com> 2023-01-12 01:19:33 +0000
commitee436e4f099c36af2b9b274c87e82d7e24ea2da8 (patch)
tree36fc8e3a47dd5c058166bb871cd98875779a3f3d
parentacb9bdad86f2ece92b767eb9f1853132e6ebe3f9 (diff)
parent8cf3e9ffbd3a5e51f86d68754cc020d5e6d9f676 (diff)
Merge changes Ibe63610f,I5d589d75
* changes: cpp binder: error if no toString implemented libbinder*: toString - support unique_ptr
-rw-r--r--libs/binder/ndk/include_cpp/android/binder_to_string.h17
1 files changed, 12 insertions, 5 deletions
diff --git a/libs/binder/ndk/include_cpp/android/binder_to_string.h b/libs/binder/ndk/include_cpp/android/binder_to_string.h
index 8d3231d985..e3ead11475 100644
--- a/libs/binder/ndk/include_cpp/android/binder_to_string.h
+++ b/libs/binder/ndk/include_cpp/android/binder_to_string.h
@@ -111,10 +111,12 @@ class IsPointerLike {
IsInstantiationOf<_U, sp>::value || // for IBinder and interface types in the C++
// backend
#endif
- IsInstantiationOf<_U, std::optional>::value || // for @nullable types in the
- // C++/NDK backends
- IsInstantiationOf<_U, std::shared_ptr>::value, // for interface types in the
- // NDK backends
+ IsInstantiationOf<_U, std::optional>::value || // for @nullable types in the
+ // C++/NDK backends
+ IsInstantiationOf<_U, std::unique_ptr>::value || // for @nullable(heap=true)
+ // in C++/NDK backends
+ IsInstantiationOf<_U, std::shared_ptr>::value, // for interface types in the
+ // NDK backends
std::true_type>
_test(int);
@@ -164,6 +166,11 @@ class ToEmptyString {
enum { value = decltype(_test<_T>(0))::value };
};
+template <typename _T>
+struct TypeDependentFalse {
+ enum { value = false };
+};
+
} // namespace details
template <typename _T>
@@ -223,7 +230,7 @@ std::string ToString(const _T& t) {
out << "]";
return out.str();
} else {
- return "{no toString() implemented}";
+ static_assert(details::TypeDependentFalse<_T>::value, "no toString implemented, huh?");
}
}