Explorar el Código

add orElse function to maybe

Kolja Strohm hace 1 año
padre
commit
6f997d2ad6
Se han modificado 1 ficheros con 8 adiciones y 0 borrados
  1. 8 0
      Maybe.h

+ 8 - 0
Maybe.h

@@ -74,6 +74,14 @@ namespace Framework
                 return Maybe<R>::empty();
         }
 
+        T orElse(T elseValue)
+        {
+			if (set)
+				return value;
+			else
+				return elseValue;
+		}
+
         T operator->()
         {
             assert(set);