diff --git a/luna/include/luna/Result.h b/luna/include/luna/Result.h index df34375b..f156b73c 100644 --- a/luna/include/luna/Result.h +++ b/luna/include/luna/Result.h @@ -41,6 +41,29 @@ template class Result { } + Result& operator=(const Result& other) + { + if (this == &other) return *this; + + m_has_value = other.m_has_value; + m_error = other.m_error; + m_value = other.m_value; + + return *this; + } + + Result& operator=(Result&& other) + { + if (this == &other) return *this; + + m_has_value = other.m_has_value; + other.m_has_value = false; + m_error = other.m_error; + m_value = move(other.m_value); + + return *this; + } + bool has_error() const { return !m_has_value; @@ -135,6 +158,26 @@ template <> class Result { } + Result& operator=(const Result& other) + { + if (this == &other) return *this; + + m_has_error = other.m_has_error; + m_error = other.m_error; + + return *this; + } + + Result& operator=(Result&& other) + { + if (this == &other) return *this; + + m_has_error = other.m_has_error; + m_error = other.m_error; + + return *this; + } + bool has_error() const { return m_has_error;