aboutsummaryrefslogtreecommitdiff
path: root/include/Result.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'include/Result.hpp')
-rw-r--r--include/Result.hpp12
1 files changed, 8 insertions, 4 deletions
diff --git a/include/Result.hpp b/include/Result.hpp
index 50a0d0c..86ae176 100644
--- a/include/Result.hpp
+++ b/include/Result.hpp
@@ -11,9 +11,7 @@ namespace amalgine
public:
static Result<T> Ok(T data)
{
- Result<T> result;
- result.data = std::move(data);
- result.errorCode = 0;
+ Result<T> result(std::move(data));
return result;
}
@@ -42,11 +40,17 @@ namespace amalgine
assert(isOk());
return data;
}
+
+ T* operator -> () {
+ assert(isOk());
+ return &data;
+ }
const std::string& getErrorMsg() const { return errorMsg; }
int getErrorCode() const { return errorCode; }
private:
- Result(){}
+ Result() {}
+ Result(T data) : data(std::move(data)), errorCode(0) {}
private:
T data;
int errorCode;