From 32c722d50943bbdeba65a77d5e94f8692cf75f3c Mon Sep 17 00:00:00 2001 From: Dominick Allen Date: Wed, 2 Oct 2024 16:19:24 -0500 Subject: Reformatting and minor documentation. --- include/fud_result.hpp | 33 ++++++++++++++++++++++----------- include/libfud.hpp | 3 +-- 2 files changed, 23 insertions(+), 13 deletions(-) (limited to 'include') 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 +/** \brief A result type which contains either a T on success or an E on error. */ +template class [[nodiscard]] Result { -public: + public: using ResultType = Result; 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(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 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 getEnv(const T& name) return getEnv(name.c_str()); } -} - +} // namespace fud #endif -- cgit v1.2.3