From 16c16064640864ee2396188eb37f58b431f8b95f Mon Sep 17 00:00:00 2001 From: Pasha Bibko <156938226+PashaBibko@users.noreply.github.com> Date: Mon, 4 Aug 2025 21:47:23 +0100 Subject: [PATCH] Added upcasting to Util::ReturnVal --- Common/modules/Result.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) 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() {};