diff options
author | Dominick Allen <djallen@librehumanitas.org> | 2024-10-02 16:19:24 -0500 |
---|---|---|
committer | Dominick Allen <djallen@librehumanitas.org> | 2024-10-02 16:19:24 -0500 |
commit | 32c722d50943bbdeba65a77d5e94f8692cf75f3c (patch) | |
tree | 119a4823b806feb1cba3f0ddb2113b6aa69ce717 | |
parent | e4345522c01f9dd760646f4a3b9ca26ee7c8812f (diff) |
Reformatting and minor documentation.
-rw-r--r-- | include/fud_result.hpp | 33 | ||||
-rw-r--r-- | include/libfud.hpp | 3 |
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 |