diff --git a/src/tcpbuffer.h b/src/tcpbuffer.h index 4320e99..492e376 100644 --- a/src/tcpbuffer.h +++ b/src/tcpbuffer.h @@ -73,6 +73,26 @@ public: that._size = 0; } + /** + * Move assignment operator + * @param that + */ + TcpBuffer &operator=(TcpBuffer &&that) + { + // skip self-assignment + if (this == &that) return *this; + + // swap buffers + _buffers.swap(that._buffers); + + // swap integers + std::swap(_skip, that._skip); + std::swap(_size, that._size); + + // done + return *this; + } + /** * Does the buffer exist (is it non-empty) * @return bool diff --git a/src/tcpconnected.h b/src/tcpconnected.h index 8c2cfec..b4ffa1f 100644 --- a/src/tcpconnected.h +++ b/src/tcpconnected.h @@ -139,7 +139,7 @@ public: buffer.shrink(processed); // restore the buffer as member - _in = std::move(buffer); + std::swap(_in, buffer); } }