Fix warnings about size conversion in QList

Because difference_type is 64-bit on 64-bit systems, there's a
downconversion warning from MSVC and possibly other compilers when it
gets passed to functions taking simply int.

Task-number: QTBUG-41092
Change-Id: I46a710810f4a57b8b84c4933f419a1f1fdf6bb5a
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
Thiago Macieira 2014-09-02 08:23:06 -07:00
parent 5368e44a86
commit c28045b118
2 changed files with 23 additions and 20 deletions

View File

@ -1363,7 +1363,7 @@ void **QListData::erase(void **xi)
\sa operator*()
*/
/*! \fn T &QList::iterator::operator[](int j) const
/*! \fn T &QList::iterator::operator[](difference_type j) const
Returns a modifiable reference to the item at position *this +
\a{j}.
@ -1464,7 +1464,7 @@ void **QListData::erase(void **xi)
current and returns an iterator to the previously current item.
*/
/*! \fn QList::iterator &QList::iterator::operator+=(int j)
/*! \fn QList::iterator &QList::iterator::operator+=(difference_type j)
Advances the iterator by \a j items. (If \a j is negative, the
iterator goes backward.)
@ -1472,7 +1472,7 @@ void **QListData::erase(void **xi)
\sa operator-=(), operator+()
*/
/*! \fn QList::iterator &QList::iterator::operator-=(int j)
/*! \fn QList::iterator &QList::iterator::operator-=(difference_type j)
Makes the iterator go back by \a j items. (If \a j is negative,
the iterator goes forward.)
@ -1480,7 +1480,7 @@ void **QListData::erase(void **xi)
\sa operator+=(), operator-()
*/
/*! \fn QList::iterator QList::iterator::operator+(int j) const
/*! \fn QList::iterator QList::iterator::operator+(difference_type j) const
Returns an iterator to the item at \a j positions forward from
this iterator. (If \a j is negative, the iterator goes backward.)
@ -1488,7 +1488,7 @@ void **QListData::erase(void **xi)
\sa operator-(), operator+=()
*/
/*! \fn QList::iterator QList::iterator::operator-(int j) const
/*! \fn QList::iterator QList::iterator::operator-(difference_type j) const
Returns an iterator to the item at \a j positions backward from
this iterator. (If \a j is negative, the iterator goes forward.)
@ -1618,7 +1618,7 @@ void **QListData::erase(void **xi)
\sa operator*()
*/
/*! \fn const T &QList::const_iterator::operator[](int j) const
/*! \fn const T &QList::const_iterator::operator[](difference_type j) const
Returns the item at position *this + \a{j}.
@ -1710,7 +1710,7 @@ void **QListData::erase(void **xi)
current and returns an iterator to the previously current item.
*/
/*! \fn QList::const_iterator &QList::const_iterator::operator+=(int j)
/*! \fn QList::const_iterator &QList::const_iterator::operator+=(difference_type j)
Advances the iterator by \a j items. (If \a j is negative, the
iterator goes backward.)
@ -1718,7 +1718,7 @@ void **QListData::erase(void **xi)
\sa operator-=(), operator+()
*/
/*! \fn QList::const_iterator &QList::const_iterator::operator-=(int j)
/*! \fn QList::const_iterator &QList::const_iterator::operator-=(difference_type j)
Makes the iterator go back by \a j items. (If \a j is negative,
the iterator goes forward.)
@ -1726,7 +1726,7 @@ void **QListData::erase(void **xi)
\sa operator+=(), operator-()
*/
/*! \fn QList::const_iterator QList::const_iterator::operator+(int j) const
/*! \fn QList::const_iterator QList::const_iterator::operator+(difference_type j) const
Returns an iterator to the item at \a j positions forward from
this iterator. (If \a j is negative, the iterator goes backward.)
@ -1734,7 +1734,7 @@ void **QListData::erase(void **xi)
\sa operator-(), operator+=()
*/
/*! \fn QList::const_iterator QList::const_iterator::operator-(int j) const
/*! \fn QList::const_iterator QList::const_iterator::operator-(difference_type j) const
Returns an iterator to the item at \a j positions backward from
this iterator. (If \a j is negative, the iterator goes forward.)

View File

@ -188,6 +188,7 @@ public:
public:
Node *i;
typedef std::random_access_iterator_tag iterator_category;
// ### Qt6: use int
typedef qptrdiff difference_type;
typedef T value_type;
typedef T *pointer;
@ -198,7 +199,7 @@ public:
inline iterator(const iterator &o): i(o.i){}
inline T &operator*() const { return i->t(); }
inline T *operator->() const { return &i->t(); }
inline T &operator[](int j) const { return i[j].t(); }
inline T &operator[](difference_type j) const { return i[j].t(); }
inline bool operator==(const iterator &o) const { return i == o.i; }
inline bool operator!=(const iterator &o) const { return i != o.i; }
inline bool operator<(const iterator& other) const { return i < other.i; }
@ -223,10 +224,10 @@ public:
inline iterator operator++(int) { Node *n = i; ++i; return n; }
inline iterator &operator--() { i--; return *this; }
inline iterator operator--(int) { Node *n = i; i--; return n; }
inline iterator &operator+=(int j) { i+=j; return *this; }
inline iterator &operator-=(int j) { i-=j; return *this; }
inline iterator operator+(int j) const { return iterator(i+j); }
inline iterator operator-(int j) const { return iterator(i-j); }
inline iterator &operator+=(difference_type j) { i+=j; return *this; }
inline iterator &operator-=(difference_type j) { i-=j; return *this; }
inline iterator operator+(difference_type j) const { return iterator(i+j); }
inline iterator operator-(difference_type j) const { return iterator(i-j); }
inline int operator-(iterator j) const { return int(i - j.i); }
};
friend class iterator;
@ -235,6 +236,7 @@ public:
public:
Node *i;
typedef std::random_access_iterator_tag iterator_category;
// ### Qt6: use int
typedef qptrdiff difference_type;
typedef T value_type;
typedef const T *pointer;
@ -250,7 +252,7 @@ public:
#endif
inline const T &operator*() const { return i->t(); }
inline const T *operator->() const { return &i->t(); }
inline const T &operator[](int j) const { return i[j].t(); }
inline const T &operator[](difference_type j) const { return i[j].t(); }
inline bool operator==(const const_iterator &o) const { return i == o.i; }
inline bool operator!=(const const_iterator &o) const { return i != o.i; }
inline bool operator<(const const_iterator& other) const { return i < other.i; }
@ -261,10 +263,10 @@ public:
inline const_iterator operator++(int) { Node *n = i; ++i; return n; }
inline const_iterator &operator--() { i--; return *this; }
inline const_iterator operator--(int) { Node *n = i; i--; return n; }
inline const_iterator &operator+=(int j) { i+=j; return *this; }
inline const_iterator &operator-=(int j) { i-=j; return *this; }
inline const_iterator operator+(int j) const { return const_iterator(i+j); }
inline const_iterator operator-(int j) const { return const_iterator(i-j); }
inline const_iterator &operator+=(difference_type j) { i+=j; return *this; }
inline const_iterator &operator-=(difference_type j) { i-=j; return *this; }
inline const_iterator operator+(difference_type j) const { return const_iterator(i+j); }
inline const_iterator operator-(difference_type j) const { return const_iterator(i-j); }
inline int operator-(const_iterator j) const { return int(i - j.i); }
};
friend class const_iterator;
@ -316,6 +318,7 @@ public:
typedef const value_type *const_pointer;
typedef value_type &reference;
typedef const value_type &const_reference;
// ### Qt6: use int
typedef qptrdiff difference_type;
// comfort