mirror of
https://github.com/catchorg/Catch2.git
synced 2024-12-22 19:33:29 +01:00
Add ops == and != for Optional
This commit is contained in:
parent
f00b6e2019
commit
f0a89b7345
@ -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)];
|
||||
|
Loading…
Reference in New Issue
Block a user