summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/fud_result.hpp33
-rw-r--r--include/libfud.hpp3
2 files changed, 23 insertions, 13 deletions
diff --git a/include/fud_result.hpp b/include/fud_result.hpp
index e4e36cf..9b96399 100644
--- a/include/fud_result.hpp
+++ b/include/fud_result.hpp
@@ -23,9 +23,10 @@
namespace fud {
-template<typename T, typename E>
+/** \brief A result type which contains either a T on success or an E on error. */
+template <typename T, typename E>
class [[nodiscard]] Result {
-public:
+ public:
using ResultType = Result<T, E>;
static ResultType okay(const T& okay)
{
@@ -49,12 +50,12 @@ public:
[[nodiscard]] constexpr bool isOkay() const
{
- return(m_value.index() == 0);
+ return (m_value.index() == 0);
}
[[nodiscard]] constexpr bool isError() const
{
- return(m_value.index() == 1);
+ return (m_value.index() == 1);
}
T getOkay()
@@ -67,17 +68,27 @@ public:
return std::get<E>(m_value);
}
-private:
- explicit Result() : m_value() {}
- explicit Result(const T& value) : m_value(value) {}
- explicit Result(const E& value) : m_value(value) {}
+ private:
+ explicit Result() : m_value()
+ {
+ }
+ explicit Result(const T& value) : m_value(value)
+ {
+ }
+ explicit Result(const E& value) : m_value(value)
+ {
+ }
- explicit Result(T&& value) : m_value(std::move(value)) {}
- explicit Result(E&& value) : m_value(std::move(value)) {}
+ explicit Result(T&& value) : m_value(std::move(value))
+ {
+ }
+ explicit Result(E&& value) : m_value(std::move(value))
+ {
+ }
std::variant<T, E> m_value;
};
-} // namespace bookmouse
+} // namespace fud
#endif
diff --git a/include/libfud.hpp b/include/libfud.hpp
index 8004df4..1e6df5d 100644
--- a/include/libfud.hpp
+++ b/include/libfud.hpp
@@ -41,7 +41,6 @@ Result<String, FudStatus> getEnv(const T& name)
return getEnv(name.c_str());
}
-}
-
+} // namespace fud
#endif