From 15d4526b3067593b5339badf935b5da763a080ff Mon Sep 17 00:00:00 2001 From: a-sum-duma <68896601+a-sum-duma@users.noreply.github.com> Date: Sat, 7 Jan 2023 17:30:44 +0100 Subject: [PATCH] Add support for Maybe Allow wrapping 'bool' with 'Maybe' --- Maybe.h | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Maybe.h b/Maybe.h index fa1be7d..a5d117b 100644 --- a/Maybe.h +++ b/Maybe.h @@ -3,6 +3,10 @@ #include "Either.h" +// helper type used for a no-value Maybe +struct Nothing {}; +Q_DECLARE_METATYPE(Nothing) + /** A simple option type implementation which represents the result * of an operation which returned either a valid result or nothing. * @@ -23,7 +27,7 @@ class Maybe * value. */ Maybe() - : m_value(false) + : m_value(Nothing()) {} /** Returns true if this Maybe has a value. */ @@ -50,7 +54,7 @@ class Maybe : m_value(value) {} - Either m_value; + Either m_value; }; template