diff --git a/Source/Engine/Core/Types/Nullable.h b/Source/Engine/Core/Types/Nullable.h index 9d8f3f65b..e1aae2ea3 100644 --- a/Source/Engine/Core/Types/Nullable.h +++ b/Source/Engine/Core/Types/Nullable.h @@ -331,6 +331,26 @@ public: { return _hasValue; } + + + /// + /// Matches the wrapped value with a handler for the value or a handler for the null value. + /// + /// Value visitor handling valid nullable value. + /// Null visitor handling invalid nullable value. + /// Result of the call of one of handlers. Handlers must share the same result type. + template + FORCE_INLINE auto Match(ValueVisitor valueHandler, NullVisitor nullHandler) const + { + if (_hasValue) + { + return valueHandler(_value); + } + else + { + return nullHandler(); + } + } }; ///