mirror of https://github.com/status-im/evmc.git
cpp: Fix evmc::result's move assignment operator
This commit is contained in:
parent
3c91910f52
commit
cea8d3a5b5
|
@ -39,16 +39,22 @@ public:
|
||||||
/// Move constructor.
|
/// Move constructor.
|
||||||
result(result&& other) noexcept : evmc_result{other}
|
result(result&& other) noexcept : evmc_result{other}
|
||||||
{
|
{
|
||||||
// Disable releaser of the rvalue object.
|
other.release = nullptr; // Disable releasing of the rvalue object.
|
||||||
other.release = nullptr;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
result(result const&) = delete;
|
result(result const&) = delete;
|
||||||
|
|
||||||
/// Move-and-swap assignment operator.
|
/// Move assignment operator.
|
||||||
result& operator=(result other) noexcept
|
///
|
||||||
|
/// The self-assigment MUST never happen.
|
||||||
|
///
|
||||||
|
/// @param other The other result object.
|
||||||
|
/// @return The reference to the left-hand side object.
|
||||||
|
result& operator=(result&& other) noexcept
|
||||||
{
|
{
|
||||||
std::swap(*this, other);
|
this->~result(); // Release this object.
|
||||||
|
static_cast<evmc_result&>(*this) = other; // Copy data.
|
||||||
|
other.release = nullptr; // Disable releasing of the rvalue object.
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue