Added upcasting to Util::ReturnVal

This commit is contained in:
Pasha Bibko
2025-08-04 21:47:23 +01:00
parent 20ef53b1c2
commit 16c1606464

View File

@@ -78,6 +78,20 @@ namespace LXC::Util
: m_Error(error.error), m_FunctionFailed(true)
{}
// Constructor to support upcasting //
template<typename Other>
requires std::is_convertible_v<Other, ResultType>
ReturnVal(ReturnVal<Other, ErrorType>&& 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() {};