From 29c2fcf8255b8286b776df593b0027b16218fae3 Mon Sep 17 00:00:00 2001
From: Pawel Wasowski
Date: Thu, 20 Feb 2020 12:52:15 +0100
Subject: [PATCH] [common][optional] Add operator==
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
---
src/common/optional.h | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/src/common/optional.h b/src/common/optional.h
index b6b2800..f476eb0 100644
--- a/src/common/optional.h
+++ b/src/common/optional.h
@@ -147,6 +147,14 @@ class optional {
ALIGNAS_TYPE(T) char value_[sizeof(T)];
};
+template
+constexpr bool operator==(const optional& a, const optional& b) {
+ if (a && b) {
+ return *a == *b;
+ }
+ return !a && !b;
+}
+
} // namespace common
#undef ALIGNAS_TYPE
--
2.7.4