From e87768a8806ee6e79ceff2ce8cea133879ef9195 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Thu, 27 Feb 2020 10:01:00 +0100 Subject: Use qsizetype for size related methods in QVarlengthArray MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: Ib94b9a4e6e17da21f592e71a36fd1b97d42dfe62 Reviewed-by: MÃ¥rten Nordheim --- src/corelib/tools/qcontainerfwd.h | 2 +- src/corelib/tools/qvarlengtharray.h | 175 ++++++++++----------- src/corelib/tools/qvarlengtharray.qdoc | 164 +++++++++---------- src/dbus/qdbusmetaobject.cpp | 4 +- src/gui/painting/qpainter.cpp | 3 +- src/gui/painting/qregion.cpp | 2 +- src/gui/rhi/qrhi.cpp | 2 +- src/plugins/sqldrivers/odbc/qsql_odbc.cpp | 4 +- .../tools/qvarlengtharray/tst_qvarlengtharray.cpp | 8 +- 9 files changed, 181 insertions(+), 183 deletions(-) diff --git a/src/corelib/tools/qcontainerfwd.h b/src/corelib/tools/qcontainerfwd.h index 0ace4473ec..bdf9e0dcc0 100644 --- a/src/corelib/tools/qcontainerfwd.h +++ b/src/corelib/tools/qcontainerfwd.h @@ -54,7 +54,7 @@ template struct QPair; template class QQueue; template class QSet; template class QStack; -template class QVarLengthArray; +template class QVarLengthArray; template class QVector; template using QList = QVector; diff --git a/src/corelib/tools/qvarlengtharray.h b/src/corelib/tools/qvarlengtharray.h index 6be695e317..a0de6bf2a1 100644 --- a/src/corelib/tools/qvarlengtharray.h +++ b/src/corelib/tools/qvarlengtharray.h @@ -57,13 +57,13 @@ QT_BEGIN_NAMESPACE // Prealloc = 256 by default, specified in qcontainerfwd.h -template +template class QVarLengthArray { public: QVarLengthArray() : QVarLengthArray(0) {} - inline explicit QVarLengthArray(int size); + inline explicit QVarLengthArray(qsizetype size); inline QVarLengthArray(const QVarLengthArray &other) : a(Prealloc), s(0), ptr(reinterpret_cast(array)) @@ -104,7 +104,7 @@ public: QVarLengthArray &operator=(std::initializer_list list) { - resize(int(list.size())); // ### q6sizetype + resize(qsizetype(list.size())); std::copy(list.begin(), list.end(), QT_MAKE_CHECKED_ARRAY_ITERATOR(this->begin(), this->size())); return *this; @@ -116,50 +116,50 @@ public: ptr[s - 1].~T(); --s; } - inline int size() const { return s; } - inline int count() const { return s; } - inline int length() const { return s; } + inline qsizetype size() const { return s; } + inline qsizetype count() const { return s; } + inline qsizetype length() const { return s; } inline T& first() { Q_ASSERT(!isEmpty()); return *begin(); } inline const T& first() const { Q_ASSERT(!isEmpty()); return *begin(); } T& last() { Q_ASSERT(!isEmpty()); return *(end() - 1); } const T& last() const { Q_ASSERT(!isEmpty()); return *(end() - 1); } inline bool isEmpty() const { return (s == 0); } - inline void resize(int size); + inline void resize(qsizetype size); inline void clear() { resize(0); } inline void squeeze(); - inline int capacity() const { return a; } - inline void reserve(int size); + inline qsizetype capacity() const { return a; } + inline void reserve(qsizetype size); - inline int indexOf(const T &t, int from = 0) const; - inline int lastIndexOf(const T &t, int from = -1) const; + inline qsizetype indexOf(const T &t, qsizetype from = 0) const; + inline qsizetype lastIndexOf(const T &t, qsizetype from = -1) const; inline bool contains(const T &t) const; - inline T &operator[](int idx) { + inline T &operator[](qsizetype idx) { Q_ASSERT(idx >= 0 && idx < s); return ptr[idx]; } - inline const T &operator[](int idx) const { + inline const T &operator[](qsizetype idx) const { Q_ASSERT(idx >= 0 && idx < s); return ptr[idx]; } - inline const T &at(int idx) const { return operator[](idx); } + inline const T &at(qsizetype idx) const { return operator[](idx); } - T value(int i) const; - T value(int i, const T &defaultValue) const; + T value(qsizetype i) const; + T value(qsizetype i, const T &defaultValue) const; inline void append(const T &t) { if (s == a) { // i.e. s != 0 T copy(t); realloc(s, s<<1); - const int idx = s++; + const qsizetype idx = s++; if (QTypeInfo::isComplex) { new (ptr + idx) T(std::move(copy)); } else { ptr[idx] = std::move(copy); } } else { - const int idx = s++; + const qsizetype idx = s++; if (QTypeInfo::isComplex) { new (ptr + idx) T(t); } else { @@ -171,14 +171,14 @@ public: void append(T &&t) { if (s == a) realloc(s, s << 1); - const int idx = s++; + const qsizetype idx = s++; if (QTypeInfo::isComplex) new (ptr + idx) T(std::move(t)); else ptr[idx] = std::move(t); } - void append(const T *buf, int size); + void append(const T *buf, qsizetype size); inline QVarLengthArray &operator<<(const T &t) { append(t); return *this; } inline QVarLengthArray &operator<<(T &&t) @@ -190,18 +190,18 @@ public: void prepend(T &&t); void prepend(const T &t); - void insert(int i, T &&t); - void insert(int i, const T &t); - void insert(int i, int n, const T &t); - void replace(int i, const T &t); - void remove(int i); - void remove(int i, int n); + void insert(qsizetype i, T &&t); + void insert(qsizetype i, const T &t); + void insert(qsizetype i, qsizetype n, const T &t); + void replace(qsizetype i, const T &t); + void remove(qsizetype i); + void remove(qsizetype i, qsizetype n); inline T *data() { return ptr; } inline const T *data() const { return ptr; } inline const T * constData() const { return ptr; } - typedef int size_type; + typedef qsizetype size_type; typedef T value_type; typedef value_type *pointer; typedef const value_type *const_pointer; @@ -229,7 +229,7 @@ public: const_reverse_iterator rend() const { return const_reverse_iterator(begin()); } const_reverse_iterator crbegin() const { return const_reverse_iterator(end()); } const_reverse_iterator crend() const { return const_reverse_iterator(begin()); } - iterator insert(const_iterator before, int n, const T &x); + iterator insert(const_iterator before, qsizetype n, const T &x); iterator insert(const_iterator before, T &&x); inline iterator insert(const_iterator before, const T &x) { return insert(before, 1, x); } iterator erase(const_iterator begin, const_iterator end); @@ -247,10 +247,10 @@ public: void shrink_to_fit() { squeeze(); } private: - void realloc(int size, int alloc); + void realloc(qsizetype size, qsizetype alloc); - int a; // capacity - int s; // size + qsizetype a; // capacity + qsizetype s; // size T *ptr; // data union { char array[Prealloc * sizeof(T)]; @@ -272,8 +272,8 @@ template QVarLengthArray; #endif -template -Q_INLINE_TEMPLATE QVarLengthArray::QVarLengthArray(int asize) +template +Q_INLINE_TEMPLATE QVarLengthArray::QVarLengthArray(qsizetype asize) : s(asize) { Q_STATIC_ASSERT_X(Prealloc > 0, "QVarLengthArray Prealloc must be greater than 0."); Q_ASSERT_X(s >= 0, "QVarLengthArray::QVarLengthArray()", "Size must be greater than or equal to 0."); @@ -292,19 +292,19 @@ Q_INLINE_TEMPLATE QVarLengthArray::QVarLengthArray(int asize) } } -template -Q_INLINE_TEMPLATE void QVarLengthArray::resize(int asize) +template +Q_INLINE_TEMPLATE void QVarLengthArray::resize(qsizetype asize) { realloc(asize, qMax(asize, a)); } -template -Q_INLINE_TEMPLATE void QVarLengthArray::reserve(int asize) +template +Q_INLINE_TEMPLATE void QVarLengthArray::reserve(qsizetype asize) { if (asize > a) realloc(s, asize); } -template -Q_INLINE_TEMPLATE int QVarLengthArray::indexOf(const T &t, int from) const +template +Q_INLINE_TEMPLATE qsizetype QVarLengthArray::indexOf(const T &t, qsizetype from) const { if (from < 0) - from = qMax(from + s, 0); + from = qMax(from + s, qsizetype(0)); if (from < s) { T *n = ptr + from - 1; T *e = ptr + s; @@ -315,8 +315,8 @@ Q_INLINE_TEMPLATE int QVarLengthArray::indexOf(const T &t, int from return -1; } -template -Q_INLINE_TEMPLATE int QVarLengthArray::lastIndexOf(const T &t, int from) const +template +Q_INLINE_TEMPLATE qsizetype QVarLengthArray::lastIndexOf(const T &t, qsizetype from) const { if (from < 0) from += s; @@ -333,7 +333,7 @@ Q_INLINE_TEMPLATE int QVarLengthArray::lastIndexOf(const T &t, int return -1; } -template +template Q_INLINE_TEMPLATE bool QVarLengthArray::contains(const T &t) const { T *b = ptr; @@ -345,14 +345,14 @@ Q_INLINE_TEMPLATE bool QVarLengthArray::contains(const T &t) const return false; } -template -Q_OUTOFLINE_TEMPLATE void QVarLengthArray::append(const T *abuf, int increment) +template +Q_OUTOFLINE_TEMPLATE void QVarLengthArray::append(const T *abuf, qsizetype increment) { Q_ASSERT(abuf); if (increment <= 0) return; - const int asize = s + increment; + const qsizetype asize = s + increment; if (asize >= a) realloc(s, qMax(s*2, asize)); @@ -367,18 +367,18 @@ Q_OUTOFLINE_TEMPLATE void QVarLengthArray::append(const T *abuf, in } } -template +template Q_INLINE_TEMPLATE void QVarLengthArray::squeeze() { realloc(s, s); } -template -Q_OUTOFLINE_TEMPLATE void QVarLengthArray::realloc(int asize, int aalloc) +template +Q_OUTOFLINE_TEMPLATE void QVarLengthArray::realloc(qsizetype asize, qsizetype aalloc) { Q_ASSERT(aalloc >= asize); T *oldPtr = ptr; - int osize = s; + qsizetype osize = s; - const int copySize = qMin(asize, osize); + const qsizetype copySize = qMin(asize, osize); Q_ASSUME(copySize >= 0); if (aalloc != a) { if (aalloc > Prealloc) { @@ -402,7 +402,7 @@ Q_OUTOFLINE_TEMPLATE void QVarLengthArray::realloc(int asize, int a } } QT_CATCH(...) { // clean up all the old objects and then free the old ptr - int sClean = s; + qsizetype sClean = s; while (sClean < osize) (oldPtr+(sClean++))->~T(); if (oldPtr != reinterpret_cast(array) && oldPtr != ptr) @@ -433,61 +433,60 @@ Q_OUTOFLINE_TEMPLATE void QVarLengthArray::realloc(int asize, int a } } -template -Q_OUTOFLINE_TEMPLATE T QVarLengthArray::value(int i) const +template +Q_OUTOFLINE_TEMPLATE T QVarLengthArray::value(qsizetype i) const { - if (uint(i) >= uint(size())) { + if (size_t(i) >= size_t(size())) return T(); - } return at(i); } -template -Q_OUTOFLINE_TEMPLATE T QVarLengthArray::value(int i, const T &defaultValue) const +template +Q_OUTOFLINE_TEMPLATE T QVarLengthArray::value(qsizetype i, const T &defaultValue) const { - return (uint(i) >= uint(size())) ? defaultValue : at(i); + return (size_t(i) >= size_t(size())) ? defaultValue : at(i); } -template -inline void QVarLengthArray::insert(int i, T &&t) +template +inline void QVarLengthArray::insert(qsizetype i, T &&t) { Q_ASSERT_X(i >= 0 && i <= s, "QVarLengthArray::insert", "index out of range"); insert(cbegin() + i, std::move(t)); } -template -inline void QVarLengthArray::insert(int i, const T &t) +template +inline void QVarLengthArray::insert(qsizetype i, const T &t) { Q_ASSERT_X(i >= 0 && i <= s, "QVarLengthArray::insert", "index out of range"); insert(begin() + i, 1, t); } -template -inline void QVarLengthArray::insert(int i, int n, const T &t) +template +inline void QVarLengthArray::insert(qsizetype i, qsizetype n, const T &t) { Q_ASSERT_X(i >= 0 && i <= s, "QVarLengthArray::insert", "index out of range"); insert(begin() + i, n, t); } -template -inline void QVarLengthArray::remove(int i, int n) +template +inline void QVarLengthArray::remove(qsizetype i, qsizetype n) { Q_ASSERT_X(i >= 0 && n >= 0 && i + n <= s, "QVarLengthArray::remove", "index out of range"); erase(begin() + i, begin() + i + n); } -template -inline void QVarLengthArray::remove(int i) +template +inline void QVarLengthArray::remove(qsizetype i) { Q_ASSERT_X(i >= 0 && i < s, "QVarLengthArray::remove", "index out of range"); erase(begin() + i, begin() + i + 1); } -template +template inline void QVarLengthArray::prepend(T &&t) { insert(cbegin(), std::move(t)); } -template +template inline void QVarLengthArray::prepend(const T &t) { insert(begin(), 1, t); } -template -inline void QVarLengthArray::replace(int i, const T &t) +template +inline void QVarLengthArray::replace(qsizetype i, const T &t) { Q_ASSERT_X(i >= 0 && i < s, "QVarLengthArray::replace", "index out of range"); const T copy(t); data()[i] = copy; } -template +template Q_OUTOFLINE_TEMPLATE typename QVarLengthArray::iterator QVarLengthArray::insert(const_iterator before, T &&t) { Q_ASSERT_X(isValidIterator(before), "QVarLengthArray::insert", "The specified const_iterator argument 'before' is invalid"); - int offset = int(before - ptr); + qsizetype offset = qsizetype(before - ptr); reserve(s + 1); if (!QTypeInfo::isRelocatable) { T *b = ptr + offset; @@ -511,12 +510,12 @@ Q_OUTOFLINE_TEMPLATE typename QVarLengthArray::iterator QVarLengthA return ptr + offset; } -template +template Q_OUTOFLINE_TEMPLATE typename QVarLengthArray::iterator QVarLengthArray::insert(const_iterator before, size_type n, const T &t) { Q_ASSERT_X(isValidIterator(before), "QVarLengthArray::insert", "The specified const_iterator argument 'before' is invalid"); - int offset = int(before - ptr); + qsizetype offset = qsizetype(before - ptr); if (n != 0) { resize(s + n); const T copy(t); @@ -540,15 +539,15 @@ Q_OUTOFLINE_TEMPLATE typename QVarLengthArray::iterator QVarLengthA return ptr + offset; } -template +template Q_OUTOFLINE_TEMPLATE typename QVarLengthArray::iterator QVarLengthArray::erase(const_iterator abegin, const_iterator aend) { Q_ASSERT_X(isValidIterator(abegin), "QVarLengthArray::insert", "The specified const_iterator argument 'abegin' is invalid"); Q_ASSERT_X(isValidIterator(aend), "QVarLengthArray::insert", "The specified const_iterator argument 'aend' is invalid"); - int f = int(abegin - ptr); - int l = int(aend - ptr); - int n = l - f; + qsizetype f = qsizetype(abegin - ptr); + qsizetype l = qsizetype(aend - ptr); + qsizetype n = l - f; if (QTypeInfo::isComplex) { std::copy(ptr + l, ptr + s, QT_MAKE_CHECKED_ARRAY_ITERATOR(ptr + f, s - f)); T *i = ptr + s; @@ -564,7 +563,7 @@ Q_OUTOFLINE_TEMPLATE typename QVarLengthArray::iterator QVarLengthA return ptr + f; } -template +template bool operator==(const QVarLengthArray &l, const QVarLengthArray &r) { if (l.size() != r.size()) @@ -575,13 +574,13 @@ bool operator==(const QVarLengthArray &l, const QVarLengthArray +template bool operator!=(const QVarLengthArray &l, const QVarLengthArray &r) { return !(l == r); } -template +template bool operator<(const QVarLengthArray &lhs, const QVarLengthArray &rhs) noexcept(noexcept(std::lexicographical_compare(lhs.begin(), lhs.end(), rhs.begin(), rhs.end()))) @@ -590,28 +589,28 @@ bool operator<(const QVarLengthArray &lhs, const QVarLengthArray +template inline bool operator>(const QVarLengthArray &lhs, const QVarLengthArray &rhs) noexcept(noexcept(lhs < rhs)) { return rhs < lhs; } -template +template inline bool operator<=(const QVarLengthArray &lhs, const QVarLengthArray &rhs) noexcept(noexcept(lhs < rhs)) { return !(lhs > rhs); } -template +template inline bool operator>=(const QVarLengthArray &lhs, const QVarLengthArray &rhs) noexcept(noexcept(lhs < rhs)) { return !(lhs < rhs); } -template +template uint qHash(const QVarLengthArray &key, uint seed = 0) noexcept(noexcept(qHashRange(key.cbegin(), key.cend(), seed))) { diff --git a/src/corelib/tools/qvarlengtharray.qdoc b/src/corelib/tools/qvarlengtharray.qdoc index d530e4358e..a20583c73a 100644 --- a/src/corelib/tools/qvarlengtharray.qdoc +++ b/src/corelib/tools/qvarlengtharray.qdoc @@ -90,7 +90,7 @@ \sa QVector, QList */ -/*! \fn template QVarLengthArray::QVarLengthArray(int size) +/*! \fn template QVarLengthArray::QVarLengthArray(qsizetype size) Constructs an array with an initial size of \a size elements. @@ -101,7 +101,7 @@ */ -/*! \fn template QVarLengthArray::QVarLengthArray(std::initializer_list args) +/*! \fn template QVarLengthArray::QVarLengthArray(std::initializer_list args) \since 5.5 Constructs an array from the std::initializer_list given by \a args. @@ -110,7 +110,7 @@ lists. */ -/*! \fn template template QVarLengthArray::QVarLengthArray(InputIterator first, InputIterator last) +/*! \fn template template QVarLengthArray::QVarLengthArray(InputIterator first, InputIterator last) \since 5.14 Constructs an array with the contents in the iterator range [\a first, \a last). @@ -119,26 +119,26 @@ */ -/*! \fn template QVarLengthArray::~QVarLengthArray() +/*! \fn template QVarLengthArray::~QVarLengthArray() Destroys the array. */ -/*! \fn template int QVarLengthArray::size() const +/*! \fn template qsizetype QVarLengthArray::size() const Returns the number of elements in the array. \sa isEmpty(), resize() */ -/*! \fn template int QVarLengthArray::count() const +/*! \fn template qsizetype QVarLengthArray::count() const Same as size(). \sa isEmpty(), resize() */ -/*! \fn template int QVarLengthArray::length() const +/*! \fn template qsizetype QVarLengthArray::length() const \since 5.0 Same as size(). @@ -146,7 +146,7 @@ \sa isEmpty(), resize() */ -/*! \fn template T& QVarLengthArray::first() +/*! \fn template T& QVarLengthArray::first() Returns a reference to the first item in the array. The array must not be empty. If the array can be empty, check isEmpty() before @@ -155,24 +155,24 @@ \sa last(), isEmpty() */ -/*! \fn template const T& QVarLengthArray::first() const +/*! \fn template const T& QVarLengthArray::first() const \overload */ -/*! \fn template T& QVarLengthArray::front() +/*! \fn template T& QVarLengthArray::front() \since 5.0 Same as first(). Provided for STL-compatibility. */ -/*! \fn template const T& QVarLengthArray::front() const +/*! \fn template const T& QVarLengthArray::front() const \since 5.0 \overload */ -/*! \fn template T& QVarLengthArray::last() +/*! \fn template T& QVarLengthArray::last() Returns a reference to the last item in the array. The array must not be empty. If the array can be empty, check isEmpty() before @@ -181,37 +181,37 @@ \sa first(), isEmpty() */ -/*! \fn template const T& QVarLengthArray::last() const +/*! \fn template const T& QVarLengthArray::last() const \overload */ -/*! \fn template T& QVarLengthArray::back() +/*! \fn template T& QVarLengthArray::back() \since 5.0 Same as last(). Provided for STL-compatibility. */ -/*! \fn template const T& QVarLengthArray::back() const +/*! \fn template const T& QVarLengthArray::back() const \since 5.0 \overload */ -/*! \fn template void QVarLengthArray::shrink_to_fit() +/*! \fn template void QVarLengthArray::shrink_to_fit() \since 5.10 Same as squeeze(). Provided for STL-compatibility. */ -/*! \fn template bool QVarLengthArray::isEmpty() const +/*! \fn template bool QVarLengthArray::isEmpty() const Returns \c true if the array has size 0; otherwise returns \c false. \sa size(), resize() */ -/*! \fn template bool QVarLengthArray::empty() const +/*! \fn template bool QVarLengthArray::empty() const \since 5.0 Returns \c true if the array has size 0; otherwise returns \c false. @@ -219,14 +219,14 @@ Same as isEmpty(). Provided for STL-compatibility. */ -/*! \fn template void QVarLengthArray::clear() +/*! \fn template void QVarLengthArray::clear() Removes all the elements from the array. Same as resize(0). */ -/*! \fn template void QVarLengthArray::resize(int size) +/*! \fn template void QVarLengthArray::resize(qsizetype size) Sets the size of the array to \a size. If \a size is greater than the current size, elements are added to the end. If \a size is @@ -240,7 +240,7 @@ \sa size(), squeeze() */ -/*! \fn template int QVarLengthArray::capacity() const +/*! \fn template qsizetype QVarLengthArray::capacity() const Returns the maximum number of elements that can be stored in the array without forcing a reallocation. @@ -253,7 +253,7 @@ \sa reserve(), squeeze() */ -/*! \fn template void QVarLengthArray::reserve(int size) +/*! \fn template void QVarLengthArray::reserve(qsizetype size) Attempts to allocate memory for at least \a size elements. If you know in advance how large the array can get, you can call this @@ -270,7 +270,7 @@ \sa capacity(), squeeze() */ -/*! \fn template void QVarLengthArray::squeeze() +/*! \fn template void QVarLengthArray::squeeze() \since 5.1 Releases any memory not required to store the items. @@ -284,7 +284,7 @@ \sa reserve(), capacity(), resize() */ -/*! \fn template T &QVarLengthArray::operator[](int i) +/*! \fn template T &QVarLengthArray::operator[](qsizetype i) Returns a reference to the item at index position \a i. @@ -294,14 +294,14 @@ \sa data(), at() */ -/*! \fn template const T &QVarLengthArray::operator[](int i) const +/*! \fn template const T &QVarLengthArray::operator[](qsizetype i) const \overload */ /*! - \fn template void QVarLengthArray::append(const T &t) + \fn template void QVarLengthArray::append(const T &t) Appends item \a t to the array, extending the array if necessary. @@ -309,7 +309,7 @@ */ /*! - \fn template void QVarLengthArray::push_back(const T &t) + \fn template void QVarLengthArray::push_back(const T &t) \since 5.0 Appends item \a t to the array, extending the array if necessary. @@ -317,7 +317,7 @@ */ /*! - \fn template void QVarLengthArray::append(T &&t) + \fn template void QVarLengthArray::append(T &&t) \overload append \since 5.9 @@ -331,7 +331,7 @@ */ /*! - \fn template void QVarLengthArray::push_back(T &&t) + \fn template void QVarLengthArray::push_back(T &&t) \overload push_back \since 5.9 @@ -345,7 +345,7 @@ */ /*! - \fn template inline void QVarLengthArray::removeLast() + \fn template inline void QVarLengthArray::removeLast() \since 4.5 Decreases the size of the array by one. The allocated size is not changed. @@ -354,20 +354,20 @@ */ /*! - \fn template void QVarLengthArray::pop_back() + \fn template void QVarLengthArray::pop_back() \since 5.0 Same as removeLast(). Provided for STL-compatibility. */ /*! - \fn template void QVarLengthArray::append(const T *buf, int size) + \fn template void QVarLengthArray::append(const T *buf, qsizetype size) Appends \a size amount of items referenced by \a buf to this array. */ -/*! \fn template T *QVarLengthArray::data() +/*! \fn template T *QVarLengthArray::data() Returns a pointer to the data stored in the array. The pointer can be used to access and modify the items in the array. @@ -383,12 +383,12 @@ \sa constData(), operator[]() */ -/*! \fn template const T *QVarLengthArray::data() const +/*! \fn template const T *QVarLengthArray::data() const \overload */ -/*! \fn template const T *QVarLengthArray::constData() const +/*! \fn template const T *QVarLengthArray::constData() const Returns a const pointer to the data stored in the array. The pointer can be used to access the items in the array. The @@ -400,11 +400,11 @@ \sa data(), operator[]() */ -/*! \fn template QVarLengthArray &QVarLengthArray::operator=(const QVarLengthArray &other) +/*! \fn template QVarLengthArray &QVarLengthArray::operator=(const QVarLengthArray &other) Assigns \a other to this array and returns a reference to this array. */ -/*! \fn template QVarLengthArray &QVarLengthArray::operator=(std::initializer_list list) +/*! \fn template QVarLengthArray &QVarLengthArray::operator=(std::initializer_list list) \since 5.5 Assigns the values of \a list to this array, and returns a reference to this array. @@ -413,11 +413,11 @@ lists. */ -/*! \fn template QVarLengthArray::QVarLengthArray(const QVarLengthArray &other) +/*! \fn template QVarLengthArray::QVarLengthArray(const QVarLengthArray &other) Constructs a copy of \a other. */ -/*! \fn template const T &QVarLengthArray::at(int i) const +/*! \fn template const T &QVarLengthArray::at(qsizetype i) const Returns a reference to the item at index position \a i. @@ -427,7 +427,7 @@ \sa value(), operator[]() */ -/*! \fn template T QVarLengthArray::value(int i) const +/*! \fn template T QVarLengthArray::value(qsizetype i) const Returns the value at index position \a i. @@ -439,7 +439,7 @@ \sa at(), operator[]() */ -/*! \fn template T QVarLengthArray::value(int i, const T &defaultValue) const +/*! \fn template T QVarLengthArray::value(qsizetype i, const T &defaultValue) const \overload @@ -525,8 +525,8 @@ */ /*! - \fn template void QVarLengthArray::prepend(const T &value) - \fn template void QVarLengthArray::prepend(T &&value) + \fn template void QVarLengthArray::prepend(const T &value) + \fn template void QVarLengthArray::prepend(T &&value) \since 4.8 Inserts \a value at the beginning of the array. @@ -542,7 +542,7 @@ \sa append(), insert() */ -/*! \fn template void QVarLengthArray::replace(int i, const T &value) +/*! \fn template void QVarLengthArray::replace(qsizetype i, const T &value) \since 4.8 Replaces the item at index position \a i with \a value. @@ -553,7 +553,7 @@ \sa operator[](), remove() */ -/*! \fn template void QVarLengthArray::remove(int i) +/*! \fn template void QVarLengthArray::remove(qsizetype i) \overload \since 4.8 @@ -563,7 +563,7 @@ \sa insert(), replace() */ -/*! \fn template void QVarLengthArray::remove(int i, int count) +/*! \fn template void QVarLengthArray::remove(qsizetype i, qsizetype count) \overload \since 4.8 @@ -574,7 +574,7 @@ \sa insert(), replace() */ -/*! \fn template QVarLengthArray::iterator QVarLengthArray::begin() +/*! \fn template QVarLengthArray::iterator QVarLengthArray::begin() \since 4.8 Returns an \l{STL-style iterators}{STL-style iterator} pointing to the first item in @@ -583,12 +583,12 @@ \sa constBegin(), end() */ -/*! \fn template QVarLengthArray::const_iterator QVarLengthArray::begin() const +/*! \fn template QVarLengthArray::const_iterator QVarLengthArray::begin() const \since 4.8 \overload */ -/*! \fn template QVarLengthArray::const_iterator QVarLengthArray::cbegin() const +/*! \fn template QVarLengthArray::const_iterator QVarLengthArray::cbegin() const \since 5.0 Returns a const \l{STL-style iterators}{STL-style iterator} pointing to the first item @@ -597,7 +597,7 @@ \sa begin(), cend() */ -/*! \fn template QVarLengthArray::const_iterator QVarLengthArray::constBegin() const +/*! \fn template QVarLengthArray::const_iterator QVarLengthArray::constBegin() const \since 4.8 Returns a const \l{STL-style iterators}{STL-style iterator} pointing to the first item @@ -606,7 +606,7 @@ \sa begin(), constEnd() */ -/*! \fn template QVarLengthArray::iterator QVarLengthArray::end() +/*! \fn template QVarLengthArray::iterator QVarLengthArray::end() \since 4.8 Returns an \l{STL-style iterators}{STL-style iterator} pointing to the imaginary item @@ -615,13 +615,13 @@ \sa begin(), constEnd() */ -/*! \fn template QVarLengthArray::const_iterator QVarLengthArray::end() const +/*! \fn template QVarLengthArray::const_iterator QVarLengthArray::end() const \since 4.8 \overload */ -/*! \fn template QVarLengthArray::const_iterator QVarLengthArray::cend() const +/*! \fn template QVarLengthArray::const_iterator QVarLengthArray::cend() const \since 5.0 Returns a const \l{STL-style iterators}{STL-style iterator} pointing to the imaginary @@ -630,7 +630,7 @@ \sa cbegin(), end() */ -/*! \fn template QVarLengthArray::const_iterator QVarLengthArray::constEnd() const +/*! \fn template QVarLengthArray::const_iterator QVarLengthArray::constEnd() const \since 4.8 Returns a const \l{STL-style iterators}{STL-style iterator} pointing to the imaginary @@ -639,7 +639,7 @@ \sa constBegin(), end() */ -/*! \fn template QVarLengthArray::reverse_iterator QVarLengthArray::rbegin() +/*! \fn template QVarLengthArray::reverse_iterator QVarLengthArray::rbegin() \since 5.6 Returns a \l{STL-style iterators}{STL-style} reverse iterator pointing to the first @@ -648,12 +648,12 @@ \sa begin(), crbegin(), rend() */ -/*! \fn template QVarLengthArray::const_reverse_iterator QVarLengthArray::rbegin() const +/*! \fn template QVarLengthArray::const_reverse_iterator QVarLengthArray::rbegin() const \since 5.6 \overload */ -/*! \fn template QVarLengthArray::const_reverse_iterator QVarLengthArray::crbegin() const +/*! \fn template QVarLengthArray::const_reverse_iterator QVarLengthArray::crbegin() const \since 5.6 Returns a const \l{STL-style iterators}{STL-style} reverse iterator pointing to the first @@ -662,7 +662,7 @@ \sa begin(), rbegin(), rend() */ -/*! \fn template QVarLengthArray::reverse_iterator QVarLengthArray::rend() +/*! \fn template QVarLengthArray::reverse_iterator QVarLengthArray::rend() \since 5.6 Returns a \l{STL-style iterators}{STL-style} reverse iterator pointing to one past @@ -671,12 +671,12 @@ \sa end(), crend(), rbegin() */ -/*! \fn template QVarLengthArray::const_reverse_iterator QVarLengthArray::rend() const +/*! \fn template QVarLengthArray::const_reverse_iterator QVarLengthArray::rend() const \since 5.6 \overload */ -/*! \fn template QVarLengthArray::const_reverse_iterator QVarLengthArray::crend() const +/*! \fn template QVarLengthArray::const_reverse_iterator QVarLengthArray::crend() const \since 5.6 Returns a const \l{STL-style iterators}{STL-style} reverse iterator pointing to one @@ -685,7 +685,7 @@ \sa end(), rend(), rbegin() */ -/*! \fn template QVarLengthArray::iterator QVarLengthArray::erase(const_iterator pos) +/*! \fn template QVarLengthArray::iterator QVarLengthArray::erase(const_iterator pos) \since 4.8 Removes the item pointed to by the iterator \a pos from the @@ -695,7 +695,7 @@ \sa insert(), remove() */ -/*! \fn template QVarLengthArray::iterator QVarLengthArray::erase(const_iterator begin, const_iterator end) +/*! \fn template QVarLengthArray::iterator QVarLengthArray::erase(const_iterator begin, const_iterator end) \overload \since 4.8 @@ -706,8 +706,8 @@ */ /*! - \fn template void QVarLengthArray::insert(int i, const T &value) - \fn template void QVarLengthArray::insert(int i, T &&value) + \fn template void QVarLengthArray::insert(qsizetype i, const T &value) + \fn template void QVarLengthArray::insert(qsizetype i, T &&value) \since 4.8 Inserts \a value at index position \a i in the array. If \a i is @@ -723,7 +723,7 @@ \sa remove() */ -/*! \fn template void QVarLengthArray::insert(int i, int count, const T &value) +/*! \fn template void QVarLengthArray::insert(qsizetype i, qsizetype count, const T &value) \overload \since 4.8 @@ -732,8 +732,8 @@ vector. */ -/*! \fn template QVarLengthArray::iterator QVarLengthArray::insert(const_iterator before, const T &value) - \fn template QVarLengthArray::iterator QVarLengthArray::insert(const_iterator before, T &&value) +/*! \fn template QVarLengthArray::iterator QVarLengthArray::insert(const_iterator before, const T &value) + \fn template QVarLengthArray::iterator QVarLengthArray::insert(const_iterator before, T &&value) \overload \since 4.8 @@ -742,7 +742,7 @@ \a before. Returns an iterator pointing at the inserted item. */ -/*! \fn template QVarLengthArray::iterator QVarLengthArray::insert(const_iterator before, int count, const T &value) +/*! \fn template QVarLengthArray::iterator QVarLengthArray::insert(const_iterator before, qsizetype count, const T &value) \since 4.8 Inserts \a count copies of \a value in front of the item pointed to @@ -752,7 +752,7 @@ -/*! \fn template bool operator==(const QVarLengthArray &left, const QVarLengthArray &right) +/*! \fn template bool operator==(const QVarLengthArray &left, const QVarLengthArray &right) \relates QVarLengthArray \since 4.8 @@ -767,7 +767,7 @@ \sa operator!=() */ -/*! \fn template bool operator!=(const QVarLengthArray &left, const QVarLengthArray &right) +/*! \fn template bool operator!=(const QVarLengthArray &left, const QVarLengthArray &right) \relates QVarLengthArray \since 4.8 @@ -782,7 +782,7 @@ \sa operator==() */ -/*! \fn template bool operator<(const QVarLengthArray &lhs, const QVarLengthArray &rhs) +/*! \fn template bool operator<(const QVarLengthArray &lhs, const QVarLengthArray &rhs) \since 5.6 \relates QVarLengthArray @@ -794,7 +794,7 @@ of \c operator<(). */ -/*! \fn template bool operator<=(const QVarLengthArray &lhs, const QVarLengthArray &rhs) +/*! \fn template bool operator<=(const QVarLengthArray &lhs, const QVarLengthArray &rhs) \since 5.6 \relates QVarLengthArray @@ -806,7 +806,7 @@ of \c operator<(). */ -/*! \fn template bool operator>(const QVarLengthArray &lhs, const QVarLengthArray &rhs) +/*! \fn template bool operator>(const QVarLengthArray &lhs, const QVarLengthArray &rhs) \since 5.6 \relates QVarLengthArray @@ -818,7 +818,7 @@ of \c operator<(). */ -/*! \fn template bool operator>=(const QVarLengthArray &lhs, const QVarLengthArray &rhs) +/*! \fn template bool operator>=(const QVarLengthArray &lhs, const QVarLengthArray &rhs) \since 5.6 \relates QVarLengthArray @@ -830,7 +830,7 @@ of \c operator<(). */ -/*! \fn template QVarLengthArray &QVarLengthArray::operator<<(const T &value) +/*! \fn template QVarLengthArray &QVarLengthArray::operator<<(const T &value) \since 4.8 Appends \a value to the array and returns a reference to this @@ -839,7 +839,7 @@ \sa append(), operator+=() */ -/*! \fn template QVarLengthArray &QVarLengthArray::operator<<(T &&value) +/*! \fn template QVarLengthArray &QVarLengthArray::operator<<(T &&value) \since 5.11 \overload @@ -847,7 +847,7 @@ \sa append(), operator+=() */ -/*! \fn template QVarLengthArray &QVarLengthArray::operator+=(const T &value) +/*! \fn template QVarLengthArray &QVarLengthArray::operator+=(const T &value) \since 4.8 Appends \a value to the array and returns a reference to this vector. @@ -855,7 +855,7 @@ \sa append(), operator<<() */ -/*! \fn template QVarLengthArray &QVarLengthArray::operator+=(T &&value) +/*! \fn template QVarLengthArray &QVarLengthArray::operator+=(T &&value) \since 5.11 \overload @@ -863,7 +863,7 @@ \sa append(), operator<<() */ -/*! \fn template int QVarLengthArray::indexOf(const T &value, int from = 0) const +/*! \fn template qsizetype QVarLengthArray::indexOf(const T &value, qsizetype from = 0) const \since 5.3 Returns the index position of the first occurrence of \a value in @@ -876,7 +876,7 @@ \sa lastIndexOf(), contains() */ -/*! \fn template int QVarLengthArray::lastIndexOf(const T &value, int from = -1) const +/*! \fn template qsizetype QVarLengthArray::lastIndexOf(const T &value, qsizetype from = -1) const \since 5.3 Returns the index position of the last occurrence of the value \a @@ -890,7 +890,7 @@ \sa indexOf(), contains() */ -/*! \fn template bool QVarLengthArray::contains(const T &value) const +/*! \fn template bool QVarLengthArray::contains(const T &value) const \since 5.3 Returns \c true if the array contains an occurrence of \a value; @@ -903,7 +903,7 @@ */ /*! - \fn template uint qHash(const QVarLengthArray &key, uint seed = 0) + \fn template uint qHash(const QVarLengthArray &key, uint seed = 0) \relates QVarLengthArray \since 5.14 diff --git a/src/dbus/qdbusmetaobject.cpp b/src/dbus/qdbusmetaobject.cpp index dcbed5a6f8..01eb1aee3f 100644 --- a/src/dbus/qdbusmetaobject.cpp +++ b/src/dbus/qdbusmetaobject.cpp @@ -391,7 +391,7 @@ int QDBusMetaObjectGenerator::aggregateParameterCount(const QMap::const_iterator it; for (it = map.constBegin(); it != map.constEnd(); ++it) { const Method &m = it.value(); - sum += m.inputTypes.size() + qMax(1, m.outputTypes.size()); + sum += m.inputTypes.size() + qMax(qsizetype(1), m.outputTypes.size()); } return sum; } @@ -460,7 +460,7 @@ void QDBusMetaObjectGenerator::write(QDBusMetaObject *obj) it != map.constEnd(); ++it) { const Method &mm = it.value(); - int argc = mm.inputTypes.size() + qMax(0, mm.outputTypes.size() - 1); + int argc = mm.inputTypes.size() + qMax(qsizetype(0), mm.outputTypes.size() - 1); idata[offset++] = strings.enter(mm.name); idata[offset++] = argc; diff --git a/src/gui/painting/qpainter.cpp b/src/gui/painting/qpainter.cpp index 49f4d7be2e..fc93ffa19f 100644 --- a/src/gui/painting/qpainter.cpp +++ b/src/gui/painting/qpainter.cpp @@ -1929,8 +1929,7 @@ bool QPainter::end() } if (d->states.size() > 1) { - qWarning("QPainter::end: Painter ended with %d saved states", - d->states.size()); + qWarning("QPainter::end: Painter ended with %d saved states", int(d->states.size())); } if (d->engine->autoDestruct()) { diff --git a/src/gui/painting/qregion.cpp b/src/gui/painting/qregion.cpp index 6409ab9528..387c23cad8 100644 --- a/src/gui/painting/qregion.cpp +++ b/src/gui/painting/qregion.cpp @@ -3561,7 +3561,7 @@ static void PtsToRegion(int numFullPtBlocks, int iCurPtBlock, int extendTo = 0; bool needsExtend = false; QVarLengthArray row; - int rowSize = 0; + qsizetype rowSize = 0; reg->extents.setLeft(INT_MAX); reg->extents.setRight(INT_MIN); diff --git a/src/gui/rhi/qrhi.cpp b/src/gui/rhi/qrhi.cpp index 83c1e8eaa2..868ce62da2 100644 --- a/src/gui/rhi/qrhi.cpp +++ b/src/gui/rhi/qrhi.cpp @@ -1252,7 +1252,7 @@ uint qHash(const QRhiVertexInputLayout &v, uint seed) Q_DECL_NOTHROW } #ifndef QT_NO_DEBUG_STREAM -template +template QDebug operator<<(QDebug dbg, const QVarLengthArray &vla) { return QtPrivate::printSequentialContainer(dbg, "VLA", vla); diff --git a/src/plugins/sqldrivers/odbc/qsql_odbc.cpp b/src/plugins/sqldrivers/odbc/qsql_odbc.cpp index 2f56487f88..d58aea9a9d 100644 --- a/src/plugins/sqldrivers/odbc/qsql_odbc.cpp +++ b/src/plugins/sqldrivers/odbc/qsql_odbc.cpp @@ -68,7 +68,7 @@ static const SQLSMALLINT TABLENAMESIZE = 128; //Map Qt parameter types to ODBC types static const SQLSMALLINT qParamType[4] = { SQL_PARAM_INPUT, SQL_PARAM_INPUT, SQL_PARAM_OUTPUT, SQL_PARAM_INPUT_OUTPUT }; -inline static QString fromSQLTCHAR(const QVarLengthArray& input, int size=-1) +inline static QString fromSQLTCHAR(const QVarLengthArray& input, qsizetype size=-1) { QString result; @@ -491,7 +491,7 @@ static QString qGetStringData(SQLHANDLE hStmt, int column, int colSize, bool uni // more data can be fetched, the length indicator does NOT // contain the number of bytes returned - it contains the // total number of bytes that CAN be fetched - int rSize = (r == SQL_SUCCESS_WITH_INFO) ? colSize : lengthIndicator; + qsizetype rSize = (r == SQL_SUCCESS_WITH_INFO) ? colSize : lengthIndicator; // Remove any trailing \0 as some drivers misguidedly append one int realsize = qMin(rSize, buf.size()); if (realsize > 0 && buf[realsize - 1] == 0) diff --git a/tests/auto/corelib/tools/qvarlengtharray/tst_qvarlengtharray.cpp b/tests/auto/corelib/tools/qvarlengtharray/tst_qvarlengtharray.cpp index 6220cc766a..74654a3862 100644 --- a/tests/auto/corelib/tools/qvarlengtharray/tst_qvarlengtharray.cpp +++ b/tests/auto/corelib/tools/qvarlengtharray/tst_qvarlengtharray.cpp @@ -448,11 +448,11 @@ QT_END_NAMESPACE bool reallocTestProceed = true; -template -int countMoved(QVarLengthArray const &c) +template +qsizetype countMoved(QVarLengthArray const &c) { - int result = 0; - for (int i = 0; i < c.size(); ++i) + qsizetype result = 0; + for (qsizetype i = 0; i < c.size(); ++i) if (c[i].hasMoved()) ++result; -- cgit v1.2.3