[zx] All comparaison operators on object_base
FIDL-121 #comment Add comparaison on handles.
Change-Id: If76cbed088b2c1c6f85c7c445c611b7d1be33111
diff --git a/system/ulib/zx/include/zx/object.h b/system/ulib/zx/include/zx/object.h
index 574fa09..03cf24e 100644
--- a/system/ulib/zx/include/zx/object.h
+++ b/system/ulib/zx/include/zx/object.h
@@ -194,6 +194,22 @@
return !(a == b);
}
+template <typename T> bool operator<(const object<T>& a, const object<T>& b) {
+ return a.get() < b.get();
+}
+
+template <typename T> bool operator>(const object<T>& a, const object<T>& b) {
+ return a.get() > b.get();
+}
+
+template <typename T> bool operator<=(const object<T>& a, const object<T>& b) {
+ return !(a.get() > b.get());
+}
+
+template <typename T> bool operator>=(const object<T>& a, const object<T>& b) {
+ return !(a.get() < b.get());
+}
+
template <typename T> bool operator==(zx_handle_t a, const object<T>& b) {
return a == b.get();
}
@@ -202,6 +218,22 @@
return !(a == b);
}
+template <typename T> bool operator<(zx_handle_t a, const object<T>& b) {
+ return a < b.get();
+}
+
+template <typename T> bool operator>(zx_handle_t a, const object<T>& b) {
+ return a > b.get();
+}
+
+template <typename T> bool operator<=(zx_handle_t a, const object<T>& b) {
+ return !(a > b.get());
+}
+
+template <typename T> bool operator>=(zx_handle_t a, const object<T>& b) {
+ return !(a < b.get());
+}
+
template <typename T> bool operator==(const object<T>& a, zx_handle_t b) {
return a.get() == b;
}
@@ -210,6 +242,22 @@
return !(a == b);
}
+template <typename T> bool operator<(const object<T>& a, zx_handle_t b) {
+ return a.get() < b;
+}
+
+template <typename T> bool operator>(const object<T>& a, zx_handle_t b) {
+ return a.get() > b;
+}
+
+template <typename T> bool operator<=(const object<T>& a, zx_handle_t b) {
+ return !(a.get() > b);
+}
+
+template <typename T> bool operator>=(const object<T>& a, zx_handle_t b) {
+ return !(a.get() < b);
+}
+
// Wraps a handle to an object to provide type-safe access to its operations
// but does not take ownership of it. The handle is not closed when the
// wrapper is destroyed.