ring buffer: Fix ambiguous comparison operators in C++20
This commit is contained in:
@@ -145,14 +145,8 @@ public:
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool operator ==(const ring_buffer_iterator_base &other) const
|
friend bool operator==(const ring_buffer_iterator &a, const ring_buffer_iterator &b) noexcept {
|
||||||
{
|
return (a.ring == b.ring) && (a.pos == b.pos);
|
||||||
return (this->ring == other.ring) && (this->pos == other.pos);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool operator !=(const ring_buffer_iterator_base &other) const
|
|
||||||
{
|
|
||||||
return !operator ==(other);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ring_buffer_iterator operator +(std::ptrdiff_t delta) const
|
ring_buffer_iterator operator +(std::ptrdiff_t delta) const
|
||||||
@@ -202,6 +196,23 @@ public:
|
|||||||
typedef ring_buffer_iterator<T, true> reverse_iterator;
|
typedef ring_buffer_iterator<T, true> reverse_iterator;
|
||||||
typedef ring_buffer_iterator<const T, true> const_reverse_iterator;
|
typedef ring_buffer_iterator<const T, true> const_reverse_iterator;
|
||||||
|
|
||||||
|
private:
|
||||||
|
static inline bool iter_equal(const ring_buffer_iterator_base &a, const ring_buffer_iterator_base &b) noexcept
|
||||||
|
{
|
||||||
|
return (a.ring == b.ring) && (a.pos == b.pos);
|
||||||
|
}
|
||||||
|
|
||||||
|
public:
|
||||||
|
friend bool operator==(const const_iterator &a, const iterator &b) noexcept
|
||||||
|
{
|
||||||
|
return ring_buffer::iter_equal(a, b);
|
||||||
|
}
|
||||||
|
|
||||||
|
friend bool operator==(const const_reverse_iterator &a, const reverse_iterator &b) noexcept
|
||||||
|
{
|
||||||
|
return ring_buffer::iter_equal(a, b);
|
||||||
|
}
|
||||||
|
|
||||||
ring_buffer() = default;
|
ring_buffer() = default;
|
||||||
|
|
||||||
template <typename U>
|
template <typename U>
|
||||||
@@ -302,11 +313,6 @@ public:
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool operator != (const ring_buffer &other) const
|
|
||||||
{
|
|
||||||
return !operator ==(other);
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t size() const
|
size_t size() const
|
||||||
{
|
{
|
||||||
return this->count;
|
return this->count;
|
||||||
|
Reference in New Issue
Block a user