mirror of
https://github.com/catchorg/Catch2.git
synced 2024-11-22 21:36:11 +01:00
Add ops == and != for Optional
This commit is contained in:
parent
f00b6e2019
commit
f0a89b7345
@ -75,6 +75,19 @@ namespace Catch {
|
|||||||
return some();
|
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:
|
private:
|
||||||
T *nullableValue;
|
T *nullableValue;
|
||||||
alignas(alignof(T)) char storage[sizeof(T)];
|
alignas(alignof(T)) char storage[sizeof(T)];
|
||||||
|
Loading…
Reference in New Issue
Block a user