diff --git a/Common/modules/Result.h b/Common/modules/Result.h index 7d264b6..444552a 100644 --- a/Common/modules/Result.h +++ b/Common/modules/Result.h @@ -78,6 +78,20 @@ namespace LXC::Util : m_Error(error.error), m_FunctionFailed(true) {} + // Constructor to support upcasting // + template + requires std::is_convertible_v + ReturnVal(ReturnVal&& other) + : m_FunctionFailed(other.m_FunctionFailed) + { + // Transfers the correct member of the union // + if (m_FunctionFailed) + m_Error = std::move(other.m_Error); + + else + m_Result = std::move(other.m_Result); + } + // Destructor // ~ReturnVal() {};