mirror of
https://github.com/RGBCube/serenity
synced 2025-05-26 04:55:07 +00:00
Kernel: Add move assign operator to KResultOr
This commit is contained in:
parent
821484f170
commit
bae8e21a8b
1 changed files with 19 additions and 1 deletions
|
@ -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)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue