diff --git a/libluna/include/luna/Buffer.h b/libluna/include/luna/Buffer.h index 6b378815..397f454c 100644 --- a/libluna/include/luna/Buffer.h +++ b/libluna/include/luna/Buffer.h @@ -11,6 +11,9 @@ class Buffer Buffer(Buffer&& other); Buffer(const Buffer& other) = delete; // For now. + Buffer& operator=(Buffer&&); + Buffer& operator=(const Buffer&) = delete; + static Result create_sized(usize size); Result try_resize(usize new_size); diff --git a/libluna/src/Buffer.cpp b/libluna/src/Buffer.cpp index 57f53051..78b7ef33 100644 --- a/libluna/src/Buffer.cpp +++ b/libluna/src/Buffer.cpp @@ -15,6 +15,16 @@ Buffer::Buffer(Buffer&& other) : m_data(other.data()), m_size(other.size()) other.m_data = nullptr; } +Buffer& Buffer::operator=(Buffer&& other) +{ + if (&other == this) return *this; + if (m_data) free_impl(m_data); + m_data = other.m_data; + m_size = other.m_size; + other.m_data = nullptr; + return *this; +} + Buffer::~Buffer() { if (m_data) free_impl(m_data);