From 5a111df9ea421a00704780a43eb581056122f1fe Mon Sep 17 00:00:00 2001
From: Patrick Wuttke
Date: Mon, 22 Sep 2025 21:42:43 +0200
Subject: [PATCH] Added void variant of Result.
---
source/mijin/types/result.hpp | 28 +++++++++++++++++++++++++++-
1 file changed, 27 insertions(+), 1 deletion(-)
diff --git a/source/mijin/types/result.hpp b/source/mijin/types/result.hpp
index a2ec4d2..3779178 100644
--- a/source/mijin/types/result.hpp
+++ b/source/mijin/types/result.hpp
@@ -60,6 +60,32 @@ public:
[[nodiscard]] const TError& getError() const MIJIN_NOEXCEPT { return std::get(state_); }
};
+namespace impl
+{
+struct ResultSuccess {};
+}
+
+template
+class ResultBase : public ResultBase
+{
+public:
+ ResultBase() MIJIN_NOEXCEPT : ResultBase(impl::ResultSuccess{}) {}
+ ResultBase(const ResultBase&) MIJIN_NOEXCEPT = default;
+ ResultBase(ResultBase&&) MIJIN_NOEXCEPT = default;
+ ResultBase(TError errorValue) MIJIN_NOEXCEPT : ResultBase(std::move(errorValue)) {}
+
+ ResultBase& operator=(const ResultBase&) = default;
+ ResultBase& operator=(ResultBase&&) = default;
+
+ impl::ResultSuccess& operator*() MIJIN_NOEXCEPT = delete;
+ const impl::ResultSuccess& operator*() const MIJIN_NOEXCEPT = delete;
+ impl::ResultSuccess* operator->() MIJIN_NOEXCEPT = delete;
+ const impl::ResultSuccess* operator->() const MIJIN_NOEXCEPT = delete;
+
+ [[nodiscard]] impl::ResultSuccess& getValue() MIJIN_NOEXCEPT = delete;
+ [[nodiscard]] const impl::ResultSuccess& getValue() const MIJIN_NOEXCEPT = delete;
+};
+
struct ResultError
{
std::string message;
@@ -73,7 +99,7 @@ struct ResultError
ResultError& operator=(ResultError&&) MIJIN_NOEXCEPT = default;
};
-template
+template
using Result = ResultBase;
//