diff options
author | Dominick Allen <djallen@librehumanitas.org> | 2024-10-09 17:28:35 -0500 |
---|---|---|
committer | Dominick Allen <djallen@librehumanitas.org> | 2024-10-09 17:28:35 -0500 |
commit | 2eaa2875f0f2523439beb623fc63146ef295c8cc (patch) | |
tree | 9bf8ccc66864b35456f449c0fd58e76600e133f4 /include/fud_result.hpp | |
parent | 79620980ea3880f6512a35b9d688a60a02ff8b98 (diff) |
Use const references and constexpr as applicable.
Diffstat (limited to 'include/fud_result.hpp')
-rw-r--r-- | include/fud_result.hpp | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/include/fud_result.hpp b/include/fud_result.hpp index 74954df..dae084a 100644 --- a/include/fud_result.hpp +++ b/include/fud_result.hpp @@ -18,7 +18,6 @@ #ifndef FUD_RESULT_HPP #define FUD_RESULT_HPP -#include <utility> #include <variant> namespace fud { @@ -58,22 +57,22 @@ class [[nodiscard]] Result { return (m_value.index() == 1); } - [[nodiscard]] T getOkay() const + [[nodiscard]] const T& getOkay() const& { return std::get<T>(m_value); } - [[nodiscard]] E getError() const + [[nodiscard]] const E& getError() const& { return std::get<E>(m_value); } - [[nodiscard]] T&& getOkay() + [[nodiscard]] const T&& getOkay() const&& { return std::move(std::get<T>(m_value)); } - [[nodiscard]] E&& getError() + [[nodiscard]] const E&& getError() const&& { return std::move(std::get<E>(m_value)); } @@ -91,7 +90,7 @@ class [[nodiscard]] Result { { } - explicit Result(T&& value) : m_value{std::move(value)} + explicit Result(T&& value): m_value{std::move(value)} { } |