Fix move assign of MonotonicBufferResource

Summary:
I was a bit stupid and thought I can use `std::swap`, while `std::swap`
is implemented in terms of move itself.

Reviewers: mtomic, mferencevic

Reviewed By: mtomic

Subscribers: pullbot

Differential Revision: https://phabricator.memgraph.io/D2054
This commit is contained in:
Teon Banek 2019-05-15 13:48:53 +02:00
parent 6082d31843
commit f9471f341d

View File

@ -52,8 +52,14 @@ MonotonicBufferResource::MonotonicBufferResource(
MonotonicBufferResource &MonotonicBufferResource::operator=( MonotonicBufferResource &MonotonicBufferResource::operator=(
MonotonicBufferResource &&other) noexcept { MonotonicBufferResource &&other) noexcept {
MonotonicBufferResource tmp(std::move(other)); if (this == &other) return *this;
std::swap(*this, tmp); Release();
memory_ = other.memory_;
current_buffer_ = other.current_buffer_;
initial_size_ = other.initial_size_;
allocated_ = other.allocated_;
other.current_buffer_ = nullptr;
other.allocated_ = 0U;
return *this; return *this;
} }