Add ops == and != for Optional

This commit is contained in:
Martin Jeřábek
2021-03-08 14:43:42 +01:00
committed by Martin Hořeňovský
parent f00b6e2019
commit f0a89b7345

View File

@ -75,6 +75,19 @@ namespace Catch {
return some();
}
friend bool operator==(Optional const& a, Optional const& b) {
if (a.none() && b.none()) {
return true;
} else if (a.some() && b.some()) {
return *a == *b;
} else {
return false;
}
}
friend bool operator!=(Optional const& a, Optional const& b) {
return !( a == b );
}
private:
T *nullableValue;
alignas(alignof(T)) char storage[sizeof(T)];