mirror of
https://github.com/fergalmoran/ladybird.git
synced 2025-12-22 09:19:03 +00:00
Kernel: Add move assign operator to KResultOr
This commit is contained in:
committed by
Andreas Kling
parent
821484f170
commit
bae8e21a8b
@@ -56,12 +56,30 @@ public:
|
|||||||
m_is_error = other.m_is_error;
|
m_is_error = other.m_is_error;
|
||||||
if (m_is_error)
|
if (m_is_error)
|
||||||
m_error = other.m_error;
|
m_error = other.m_error;
|
||||||
else
|
else {
|
||||||
new (&m_storage) T(move(other.value()));
|
new (&m_storage) T(move(other.value()));
|
||||||
|
other.value().~T();
|
||||||
|
}
|
||||||
other.m_is_error = true;
|
other.m_is_error = true;
|
||||||
other.m_error = KSuccess;
|
other.m_error = KSuccess;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
KResultOr& operator=(KResultOr&& other)
|
||||||
|
{
|
||||||
|
if (!m_is_error)
|
||||||
|
value().~T();
|
||||||
|
m_is_error = other.m_is_error;
|
||||||
|
if (m_is_error)
|
||||||
|
m_error = other.m_error;
|
||||||
|
else {
|
||||||
|
new (&m_storage) T(move(other.value()));
|
||||||
|
other.value().~T();
|
||||||
|
}
|
||||||
|
other.m_is_error = true;
|
||||||
|
other.m_error = KSuccess;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
~KResultOr()
|
~KResultOr()
|
||||||
{
|
{
|
||||||
if (!m_is_error)
|
if (!m_is_error)
|
||||||
|
|||||||
Reference in New Issue
Block a user