Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions Maybe.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand All @@ -23,7 +27,7 @@ class Maybe
* value.
*/
Maybe()
: m_value(false)
: m_value(Nothing())
{}

/** Returns true if this Maybe<T> has a value. */
Expand All @@ -50,7 +54,7 @@ class Maybe
: m_value(value)
{}

Either<bool,T> m_value;
Either<Nothing,T> m_value;
};

template <class T>
Expand Down