diff --git a/include/evmc/evmc.hpp b/include/evmc/evmc.hpp index 1ae2d12..b829a15 100644 --- a/include/evmc/evmc.hpp +++ b/include/evmc/evmc.hpp @@ -39,16 +39,22 @@ public: /// Move constructor. result(result&& other) noexcept : evmc_result{other} { - // Disable releaser of the rvalue object. - other.release = nullptr; + other.release = nullptr; // Disable releasing of the rvalue object. } result(result const&) = delete; - /// Move-and-swap assignment operator. - result& operator=(result other) noexcept + /// Move assignment operator. + /// + /// 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(*this) = other; // Copy data. + other.release = nullptr; // Disable releasing of the rvalue object. return *this; }