diff options
| author | Martin Jeřábek | 2021-03-08 14:43:42 +0100 |
|---|---|---|
| committer | Martin Hořeňovský | 2021-12-29 16:58:16 +0100 |
| commit | f0a89b7345f84436c2af142e39ba304189d3851f (patch) | |
| tree | 42fe94c13efd4e2706e29bd3e082e6953f586e4b /src/catch2 | |
| parent | f00b6e2019a9e5bdbe37dcc0be5756322363909d (diff) | |
| download | catch3-f0a89b7345f84436c2af142e39ba304189d3851f.tar.gz | |
Add ops == and != for Optional
Diffstat (limited to 'src/catch2')
| -rw-r--r-- | src/catch2/internal/catch_optional.hpp | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/catch2/internal/catch_optional.hpp b/src/catch2/internal/catch_optional.hpp index e2d7b057..fb7ebbb6 100644 --- a/src/catch2/internal/catch_optional.hpp +++ b/src/catch2/internal/catch_optional.hpp @@ -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)]; |