QList: add mixed comparison operators between (const_)iterators
It is currently possible to compare a QList iterator with a const_iterator and viceversa, even though these operations aren't defined, because they are actually routed through the relational operators between iterators and raw pointers after a conversion (!). With the deprecation of iterator->pointer implicit conversions, this is going to break, so add the missig mixed comparison operators. Change-Id: Ic645ab0246f79f64b04334ecd02e9fe8fa46f0fa Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
parent
be3df082bc
commit
ad972af8fb
@ -129,8 +129,10 @@ public:
|
|||||||
using rvalue_ref = T &&;
|
using rvalue_ref = T &&;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
class const_iterator;
|
||||||
class iterator {
|
class iterator {
|
||||||
friend class QList<T>;
|
friend class QList<T>;
|
||||||
|
friend class const_iterator;
|
||||||
T *i = nullptr;
|
T *i = nullptr;
|
||||||
public:
|
public:
|
||||||
using difference_type = qsizetype;
|
using difference_type = qsizetype;
|
||||||
@ -157,6 +159,12 @@ public:
|
|||||||
inline constexpr bool operator<=(iterator other) const { return i <= other.i; }
|
inline constexpr bool operator<=(iterator other) const { return i <= other.i; }
|
||||||
inline constexpr bool operator>(iterator other) const { return i > other.i; }
|
inline constexpr bool operator>(iterator other) const { return i > other.i; }
|
||||||
inline constexpr bool operator>=(iterator other) const { return i >= other.i; }
|
inline constexpr bool operator>=(iterator other) const { return i >= other.i; }
|
||||||
|
inline constexpr bool operator==(const_iterator o) const { return i == o.i; }
|
||||||
|
inline constexpr bool operator!=(const_iterator o) const { return i != o.i; }
|
||||||
|
inline constexpr bool operator<(const_iterator other) const { return i < other.i; }
|
||||||
|
inline constexpr bool operator<=(const_iterator other) const { return i <= other.i; }
|
||||||
|
inline constexpr bool operator>(const_iterator other) const { return i > other.i; }
|
||||||
|
inline constexpr bool operator>=(const_iterator other) const { return i >= other.i; }
|
||||||
inline constexpr bool operator==(pointer p) const { return i == p; }
|
inline constexpr bool operator==(pointer p) const { return i == p; }
|
||||||
inline constexpr bool operator!=(pointer p) const { return i != p; }
|
inline constexpr bool operator!=(pointer p) const { return i != p; }
|
||||||
inline iterator &operator++() { ++i; return *this; }
|
inline iterator &operator++() { ++i; return *this; }
|
||||||
@ -180,6 +188,7 @@ public:
|
|||||||
|
|
||||||
class const_iterator {
|
class const_iterator {
|
||||||
friend class QList<T>;
|
friend class QList<T>;
|
||||||
|
friend class iterator;
|
||||||
const T *i = nullptr;
|
const T *i = nullptr;
|
||||||
public:
|
public:
|
||||||
using difference_type = qsizetype;
|
using difference_type = qsizetype;
|
||||||
@ -206,8 +215,12 @@ public:
|
|||||||
inline constexpr bool operator<=(const_iterator other) const { return i <= other.i; }
|
inline constexpr bool operator<=(const_iterator other) const { return i <= other.i; }
|
||||||
inline constexpr bool operator>(const_iterator other) const { return i > other.i; }
|
inline constexpr bool operator>(const_iterator other) const { return i > other.i; }
|
||||||
inline constexpr bool operator>=(const_iterator other) const { return i >= other.i; }
|
inline constexpr bool operator>=(const_iterator other) const { return i >= other.i; }
|
||||||
inline constexpr bool operator==(iterator o) const { return i == const_iterator(o).i; }
|
inline constexpr bool operator==(iterator o) const { return i == o.i; }
|
||||||
inline constexpr bool operator!=(iterator o) const { return i != const_iterator(o).i; }
|
inline constexpr bool operator!=(iterator o) const { return i != o.i; }
|
||||||
|
inline constexpr bool operator<(iterator other) const { return i < other.i; }
|
||||||
|
inline constexpr bool operator<=(iterator other) const { return i <= other.i; }
|
||||||
|
inline constexpr bool operator>(iterator other) const { return i > other.i; }
|
||||||
|
inline constexpr bool operator>=(iterator other) const { return i >= other.i; }
|
||||||
inline constexpr bool operator==(pointer p) const { return i == p; }
|
inline constexpr bool operator==(pointer p) const { return i == p; }
|
||||||
inline constexpr bool operator!=(pointer p) const { return i != p; }
|
inline constexpr bool operator!=(pointer p) const { return i != p; }
|
||||||
inline const_iterator &operator++() { ++i; return *this; }
|
inline const_iterator &operator++() { ++i; return *this; }
|
||||||
|
Loading…
x
Reference in New Issue
Block a user