mirror of
https://github.com/PCSX2/pcsx2.git
synced 2026-07-11 01:34:17 +02:00
HeapArray: Fix comparison operators
This commit is contained in:
+16
-34
@@ -87,24 +87,15 @@ public:
|
||||
return *this;
|
||||
}
|
||||
|
||||
#define RELATIONAL_OPERATOR(op) \
|
||||
bool operator op(const this_type& rhs) const \
|
||||
{ \
|
||||
for (size_type i = 0; i < SIZE; i++) \
|
||||
{ \
|
||||
if (!(m_data[i] op rhs.m_data[i])) \
|
||||
return false; \
|
||||
} \
|
||||
bool operator==(const this_type& rhs) const
|
||||
{
|
||||
return std::equal(m_data, m_data + SIZE, rhs.m_data, rhs.m_data + SIZE);
|
||||
}
|
||||
|
||||
RELATIONAL_OPERATOR(==);
|
||||
RELATIONAL_OPERATOR(!=);
|
||||
RELATIONAL_OPERATOR(<);
|
||||
RELATIONAL_OPERATOR(<=);
|
||||
RELATIONAL_OPERATOR(>);
|
||||
RELATIONAL_OPERATOR(>=);
|
||||
|
||||
#undef RELATIONAL_OPERATOR
|
||||
auto operator<=>(const this_type& rhs) const
|
||||
{
|
||||
return std::lexicographical_compare_three_way(m_data, m_data + SIZE, rhs.m_data, rhs.m_data + SIZE);
|
||||
}
|
||||
|
||||
private:
|
||||
void allocate()
|
||||
@@ -337,26 +328,17 @@ public:
|
||||
return *this;
|
||||
}
|
||||
|
||||
#define RELATIONAL_OPERATOR(op, size_op) \
|
||||
bool operator op(const this_type& rhs) const \
|
||||
{ \
|
||||
if (m_size != rhs.m_size) \
|
||||
return m_size size_op rhs.m_size; \
|
||||
for (size_type i = 0; i < m_size; i++) \
|
||||
{ \
|
||||
if (!(m_data[i] op rhs.m_data[i])) \
|
||||
return false; \
|
||||
} \
|
||||
bool operator==(const this_type& rhs) const
|
||||
{
|
||||
return std::equal(m_data, m_data + m_size, rhs.m_data, rhs.m_data + rhs.m_size);
|
||||
}
|
||||
|
||||
RELATIONAL_OPERATOR(==, !=);
|
||||
RELATIONAL_OPERATOR(!=, ==);
|
||||
RELATIONAL_OPERATOR(<, <);
|
||||
RELATIONAL_OPERATOR(<=, <=);
|
||||
RELATIONAL_OPERATOR(>, >);
|
||||
RELATIONAL_OPERATOR(>=, >=);
|
||||
|
||||
#undef RELATIONAL_OPERATOR
|
||||
auto operator<=>(const this_type& rhs) const
|
||||
{
|
||||
return std::lexicographical_compare_three_way(
|
||||
m_data, m_data + m_size,
|
||||
rhs.m_data, rhs.m_data + rhs.m_size);
|
||||
}
|
||||
|
||||
private:
|
||||
void internal_resize(size_t size, T* prev_ptr, size_t prev_size)
|
||||
|
||||
Reference in New Issue
Block a user