Added upcasting to Util::ReturnVal
This commit is contained in:
@@ -78,6 +78,20 @@ namespace LXC::Util
|
|||||||
: m_Error(error.error), m_FunctionFailed(true)
|
: 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 //
|
// Destructor //
|
||||||
~ReturnVal() {};
|
~ReturnVal() {};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user