[common][optional] Add operator== 31/225531/5
authorPawel Wasowski <p.wasowski2@samsung.com>
Thu, 20 Feb 2020 11:52:15 +0000 (12:52 +0100)
committerPawel Wasowski <p.wasowski2@samsung.com>
Wed, 26 Feb 2020 11:24:40 +0000 (12:24 +0100)
Verification: the compilation doesn't fail; further validation will be
done when the operator will be used in the UUID class code

Change-Id: If7bee4f1f4b5d994aeaa11d32e2e2371397e94ba
Signed-off-by: Pawel Wasowski <p.wasowski2@samsung.com>
src/common/optional.h

index b6b2800..f476eb0 100644 (file)
@@ -147,6 +147,14 @@ class optional {
   ALIGNAS_TYPE(T) char value_[sizeof(T)];
 };
 
+template <class T, class U>
+constexpr bool operator==(const optional<T>& a, const optional<U>& b) {
+  if (a && b) {
+    return *a == *b;
+  }
+  return !a && !b;
+}
+
 }  // namespace common
 
 #undef ALIGNAS_TYPE