Read-only mirrors. Development, issues and pull requests are on GitHub.

summaryrefslogtreecommitdiffhomepage
path: root/src/catch2/internal
diff options
context:
space:
mode:
authorMartin Jeřábek2021-03-08 14:43:42 +0100
committerMartin Hořeňovský2021-12-29 16:58:16 +0100
commitf0a89b7345f84436c2af142e39ba304189d3851f (patch)
tree42fe94c13efd4e2706e29bd3e082e6953f586e4b /src/catch2/internal
parentf00b6e2019a9e5bdbe37dcc0be5756322363909d (diff)
downloadcatch3-f0a89b7345f84436c2af142e39ba304189d3851f.tar.gz
Add ops == and != for Optional
Diffstat (limited to 'src/catch2/internal')
-rw-r--r--src/catch2/internal/catch_optional.hpp13
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)];