mirror of
https://github.com/SerenityOS/serenity.git
synced 2025-01-23 09:51:57 -05:00
AK: Fix -Wconsumed warnings in Optional move-ctor and move-assign
Our protocol says we have to call has_value() before release_value(). The code was already safe, but the compiler had no way of knowing that.
This commit is contained in:
parent
0f7eece141
commit
60c25228ee
1 changed files with 2 additions and 3 deletions
|
@ -28,7 +28,7 @@ public:
|
|||
Optional(Optional&& other)
|
||||
: m_has_value(other.m_has_value)
|
||||
{
|
||||
if (m_has_value) {
|
||||
if (other.has_value()) {
|
||||
new (&m_storage) T(other.release_value());
|
||||
other.m_has_value = false;
|
||||
}
|
||||
|
@ -62,9 +62,8 @@ public:
|
|||
if (this != &other) {
|
||||
clear();
|
||||
m_has_value = other.m_has_value;
|
||||
if (m_has_value) {
|
||||
if (other.has_value())
|
||||
new (&m_storage) T(other.release_value());
|
||||
}
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue