libluna: Add assignment operators to Buffer
This commit is contained in:
parent
653b2074c0
commit
a5d33fdf44
@ -11,6 +11,9 @@ class Buffer
|
|||||||
Buffer(Buffer&& other);
|
Buffer(Buffer&& other);
|
||||||
Buffer(const Buffer& other) = delete; // For now.
|
Buffer(const Buffer& other) = delete; // For now.
|
||||||
|
|
||||||
|
Buffer& operator=(Buffer&&);
|
||||||
|
Buffer& operator=(const Buffer&) = delete;
|
||||||
|
|
||||||
static Result<Buffer> create_sized(usize size);
|
static Result<Buffer> create_sized(usize size);
|
||||||
|
|
||||||
Result<void> try_resize(usize new_size);
|
Result<void> try_resize(usize new_size);
|
||||||
|
@ -15,6 +15,16 @@ Buffer::Buffer(Buffer&& other) : m_data(other.data()), m_size(other.size())
|
|||||||
other.m_data = nullptr;
|
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()
|
Buffer::~Buffer()
|
||||||
{
|
{
|
||||||
if (m_data) free_impl(m_data);
|
if (m_data) free_impl(m_data);
|
||||||
|
Loading…
Reference in New Issue
Block a user