Make wxVector::reverse_iterator satisfy RandomAccessIterator
RandomAccessIterator requirements include LessThanComparable, so implement the missing comparison operators for this class, as well as for const_reverse_iterator. This also fixes compilation problems with MSVS 2013 in debug mode, where the CRT uses these operators to check the iterators correctness. See https://github.com/wxWidgets/wxWidgets/pull/1048
This commit is contained in:
@@ -219,6 +219,14 @@ public:
|
|||||||
{ return m_ptr == it.m_ptr; }
|
{ return m_ptr == it.m_ptr; }
|
||||||
bool operator !=(const reverse_iterator& it) const
|
bool operator !=(const reverse_iterator& it) const
|
||||||
{ return m_ptr != it.m_ptr; }
|
{ return m_ptr != it.m_ptr; }
|
||||||
|
bool operator<(const reverse_iterator& it) const
|
||||||
|
{ return m_ptr > it.m_ptr; }
|
||||||
|
bool operator>(const reverse_iterator& it) const
|
||||||
|
{ return m_ptr < it.m_ptr; }
|
||||||
|
bool operator<=(const reverse_iterator& it) const
|
||||||
|
{ return m_ptr >= it.m_ptr; }
|
||||||
|
bool operator>=(const reverse_iterator& it) const
|
||||||
|
{ return m_ptr <= it.m_ptr; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
value_type *m_ptr;
|
value_type *m_ptr;
|
||||||
@@ -274,6 +282,14 @@ public:
|
|||||||
{ return m_ptr == it.m_ptr; }
|
{ return m_ptr == it.m_ptr; }
|
||||||
bool operator !=(const const_reverse_iterator& it) const
|
bool operator !=(const const_reverse_iterator& it) const
|
||||||
{ return m_ptr != it.m_ptr; }
|
{ return m_ptr != it.m_ptr; }
|
||||||
|
bool operator<(const const_reverse_iterator& it) const
|
||||||
|
{ return m_ptr > it.m_ptr; }
|
||||||
|
bool operator>(const const_reverse_iterator& it) const
|
||||||
|
{ return m_ptr < it.m_ptr; }
|
||||||
|
bool operator<=(const const_reverse_iterator& it) const
|
||||||
|
{ return m_ptr >= it.m_ptr; }
|
||||||
|
bool operator>=(const const_reverse_iterator& it) const
|
||||||
|
{ return m_ptr <= it.m_ptr; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
const value_type *m_ptr;
|
const value_type *m_ptr;
|
||||||
|
@@ -365,6 +365,13 @@ TEST_CASE("wxVector::reverse_iterator", "[vector][reverse_iterator]")
|
|||||||
CHECK( ri - rb == 2 );
|
CHECK( ri - rb == 2 );
|
||||||
CHECK( re - ri == 8 );
|
CHECK( re - ri == 8 );
|
||||||
|
|
||||||
|
CHECK( rb < ri );
|
||||||
|
CHECK( rb <= ri );
|
||||||
|
CHECK( ri <= ri );
|
||||||
|
CHECK( ri >= ri );
|
||||||
|
CHECK( ri < re );
|
||||||
|
CHECK( ri <= re );
|
||||||
|
|
||||||
#if wxUSE_STD_CONTAINERS_COMPATIBLY
|
#if wxUSE_STD_CONTAINERS_COMPATIBLY
|
||||||
std::vector<int> stdvec(rb, re);
|
std::vector<int> stdvec(rb, re);
|
||||||
REQUIRE( stdvec.size() == 10 );
|
REQUIRE( stdvec.size() == 10 );
|
||||||
|
Reference in New Issue
Block a user