Ring buffer: Add swap function, make move (swap) assignment noexcept
This commit is contained in:
@@ -227,7 +227,7 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
ring_buffer(ring_buffer &&other)
|
||||
ring_buffer(ring_buffer &&other) noexcept
|
||||
{
|
||||
std::swap(this->data, other.data);
|
||||
std::swap(this->head, other.head);
|
||||
@@ -264,7 +264,7 @@ public:
|
||||
return *this;
|
||||
}
|
||||
|
||||
ring_buffer& operator =(ring_buffer &&other)
|
||||
ring_buffer& operator =(ring_buffer &&other) noexcept
|
||||
{
|
||||
if (&other != this) {
|
||||
std::swap(this->data, other.data);
|
||||
@@ -282,6 +282,14 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
void swap(ring_buffer &other) noexcept
|
||||
{
|
||||
std::swap(this->data, other.data);
|
||||
std::swap(this->head, other.head);
|
||||
std::swap(this->count, other.count);
|
||||
std::swap(this->mask, other.mask);
|
||||
}
|
||||
|
||||
bool operator ==(const ring_buffer& other) const
|
||||
{
|
||||
if (this->count != other.count) return false;
|
||||
|
Reference in New Issue
Block a user