Move implementation of QVector/List back to qlist.h
And name the main class QList. That's also the one we document. This gives less porting pain for our users, and a lot less churn in our API, as we use QList in Qt 5 in 95% of our API. In addition, it gives more consistent naming with QStringList and QByteArrayList and disambiguates QList vs QVector(2|3|4)D. Fixes: QTBUG-84468 Change-Id: I3cba9d1d3179969d8bf9320b31be2230d021d1a9 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>bb10
parent
1a9a4af388
commit
03326a2fec
|
|
@ -49,18 +49,18 @@
|
|||
****************************************************************************/
|
||||
|
||||
//! [0]
|
||||
QVector<int> integerVector;
|
||||
QVector<QString> stringVector;
|
||||
QList<int> integerVector;
|
||||
QList<QString> stringVector;
|
||||
//! [0]
|
||||
|
||||
|
||||
//! [1]
|
||||
QVector<QString> vector(200);
|
||||
QList<QString> vector(200);
|
||||
//! [1]
|
||||
|
||||
|
||||
//! [2]
|
||||
QVector<QString> vector(200, "Pass");
|
||||
QList<QString> vector(200, "Pass");
|
||||
//! [2]
|
||||
|
||||
|
||||
|
|
@ -86,7 +86,7 @@ if (i != -1)
|
|||
|
||||
|
||||
//! [6]
|
||||
QVector<int> vector(10);
|
||||
QList<int> vector(10);
|
||||
int *data = vector.data();
|
||||
for (int i = 0; i < 10; ++i)
|
||||
data[i] = 2 * i;
|
||||
|
|
@ -94,7 +94,7 @@ for (int i = 0; i < 10; ++i)
|
|||
|
||||
|
||||
//! [7]
|
||||
QVector<QString> vector;
|
||||
QList<QString> vector;
|
||||
vector.append("one");
|
||||
vector.append("two");
|
||||
QString three = "three";
|
||||
|
|
@ -105,7 +105,7 @@ vector.append(three);
|
|||
|
||||
|
||||
//! [move-append]
|
||||
QVector<QString> vector;
|
||||
QList<QString> vector;
|
||||
vector.append("one");
|
||||
vector.append("two");
|
||||
QString three = "three";
|
||||
|
|
@ -116,14 +116,14 @@ vector.append(std::move(three));
|
|||
|
||||
|
||||
//! [emplace]
|
||||
QVector<QString> vector{"a", "ccc"};
|
||||
QList<QString> vector{"a", "ccc"};
|
||||
vector.emplace(1, 2, 'b');
|
||||
// vector: ["a", "bb", "ccc"]
|
||||
//! [emplace]
|
||||
|
||||
|
||||
//! [emplace-back]
|
||||
QVector<QString> vector{"one", "two"};
|
||||
QList<QString> vector{"one", "two"};
|
||||
vector.emplaceBack(3, 'a');
|
||||
qDebug() << vector;
|
||||
// vector: ["one", "two", "aaa"]
|
||||
|
|
@ -131,7 +131,7 @@ qDebug() << vector;
|
|||
|
||||
|
||||
//! [emplace-back-ref]
|
||||
QVector<QString> vector;
|
||||
QList<QString> vector;
|
||||
auto &ref = vector.emplaceBack();
|
||||
ref = "one";
|
||||
// vector: ["one"]
|
||||
|
|
@ -139,7 +139,7 @@ ref = "one";
|
|||
|
||||
|
||||
//! [8]
|
||||
QVector<QString> vector;
|
||||
QList<QString> vector;
|
||||
vector.prepend("one");
|
||||
vector.prepend("two");
|
||||
vector.prepend("three");
|
||||
|
|
@ -148,7 +148,7 @@ vector.prepend("three");
|
|||
|
||||
|
||||
//! [9]
|
||||
QVector<QString> vector;
|
||||
QList<QString> vector;
|
||||
vector << "alpha" << "beta" << "delta";
|
||||
vector.insert(2, "gamma");
|
||||
// vector: ["alpha", "beta", "gamma", "delta"]
|
||||
|
|
@ -156,7 +156,7 @@ vector.insert(2, "gamma");
|
|||
|
||||
|
||||
//! [10]
|
||||
QVector<double> vector;
|
||||
QList<double> vector;
|
||||
vector << 2.718 << 1.442 << 0.4342;
|
||||
vector.insert(1, 3, 9.9);
|
||||
// vector: [2.718, 9.9, 9.9, 9.9, 1.442, 0.4342]
|
||||
|
|
@ -164,7 +164,7 @@ vector.insert(1, 3, 9.9);
|
|||
|
||||
|
||||
//! [11]
|
||||
QVector<QString> vector(3);
|
||||
QList<QString> vector(3);
|
||||
vector.fill("Yes");
|
||||
// vector: ["Yes", "Yes", "Yes"]
|
||||
|
||||
|
|
@ -174,7 +174,7 @@ vector.fill("oh", 5);
|
|||
|
||||
|
||||
//! [12]
|
||||
QVector<QString> vector;
|
||||
QList<QString> vector;
|
||||
vector << "A" << "B" << "C" << "B" << "A";
|
||||
vector.indexOf("B"); // returns 1
|
||||
vector.indexOf("B", 1); // returns 1
|
||||
|
|
@ -192,37 +192,18 @@ vector.lastIndexOf("B", 2); // returns 1
|
|||
vector.lastIndexOf("X"); // returns -1
|
||||
//! [13]
|
||||
|
||||
|
||||
//! [14]
|
||||
QVector<double> vect;
|
||||
vect << "red" << "green" << "blue" << "black";
|
||||
|
||||
QList<double> list = vect.toList();
|
||||
// list: ["red", "green", "blue", "black"]
|
||||
//! [14]
|
||||
|
||||
|
||||
//! [15]
|
||||
QStringList list;
|
||||
list << "Sven" << "Kim" << "Ola";
|
||||
|
||||
QVector<QString> vect = QVector<QString>::fromList(list);
|
||||
// vect: ["Sven", "Kim", "Ola"]
|
||||
//! [15]
|
||||
|
||||
|
||||
//! [16]
|
||||
std::vector<double> stdvector;
|
||||
vector.push_back(1.2);
|
||||
vector.push_back(0.5);
|
||||
vector.push_back(3.14);
|
||||
|
||||
QVector<double> vector = QVector<double>::fromStdVector(stdvector);
|
||||
QList<double> vector = QList<double>::fromStdVector(stdvector);
|
||||
//! [16]
|
||||
|
||||
|
||||
//! [17]
|
||||
QVector<double> vector;
|
||||
QList<double> vector;
|
||||
vector << 1.2 << 0.5 << 3.14;
|
||||
|
||||
std::vector<double> stdvector = vector.toStdVector();
|
||||
|
|
@ -182,7 +182,7 @@ public: \
|
|||
}; \
|
||||
}
|
||||
|
||||
Q_DECLARE_MOVABLE_CONTAINER(QVector);
|
||||
Q_DECLARE_MOVABLE_CONTAINER(QList);
|
||||
Q_DECLARE_MOVABLE_CONTAINER(QQueue);
|
||||
Q_DECLARE_MOVABLE_CONTAINER(QStack);
|
||||
Q_DECLARE_MOVABLE_CONTAINER(QSet);
|
||||
|
|
|
|||
|
|
@ -223,7 +223,7 @@ Q_DECLARE_OPERATORS_FOR_FLAGS(QItemSelectionModel::SelectionFlags)
|
|||
# define Q_TEMPLATE_EXTERN extern
|
||||
# endif
|
||||
# endif
|
||||
Q_TEMPLATE_EXTERN template class Q_CORE_EXPORT QVector<QItemSelectionRange>;
|
||||
Q_TEMPLATE_EXTERN template class Q_CORE_EXPORT QList<QItemSelectionRange>;
|
||||
#endif // Q_CC_MSVC
|
||||
|
||||
class Q_CORE_EXPORT QItemSelection : public QList<QItemSelectionRange>
|
||||
|
|
|
|||
|
|
@ -682,7 +682,7 @@ static void argumentTypesFromString(const char *str, const char *end,
|
|||
++str;
|
||||
}
|
||||
QByteArray argType(begin, str - begin);
|
||||
argType.replace("QList<", "QVector<");
|
||||
argType.replace("QVector<", "QList<");
|
||||
types += QArgumentType(std::move(argType));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -232,7 +232,7 @@ inline Q_DECL_CONSTEXPR int qMetaTypeId();
|
|||
TypeName = Id,
|
||||
|
||||
#define QT_FOR_EACH_AUTOMATIC_TEMPLATE_1ARG(F) \
|
||||
F(QVector) \
|
||||
F(QList) \
|
||||
F(QQueue) \
|
||||
F(QStack) \
|
||||
F(QSet) \
|
||||
|
|
@ -2014,7 +2014,7 @@ typedef QHash<QString, QVariant> QVariantHash;
|
|||
#ifdef Q_CLANG_QDOC
|
||||
class QByteArrayList;
|
||||
#else
|
||||
typedef QVector<QByteArray> QByteArrayList;
|
||||
using QByteArrayList = QList<QByteArray>;
|
||||
#endif
|
||||
|
||||
#define Q_DECLARE_METATYPE_TEMPLATE_1ARG(SINGLE_ARG_TEMPLATE) \
|
||||
|
|
@ -2515,9 +2515,9 @@ public:
|
|||
}
|
||||
#endif
|
||||
|
||||
if (skipToken(begin, end, "QList")) {
|
||||
// Replace QList by QVector
|
||||
appendStr("QVector");
|
||||
if (skipToken(begin, end, "QVector")) {
|
||||
// Replace QVector by QList
|
||||
appendStr("QList");
|
||||
}
|
||||
|
||||
if (skipToken(begin, end, "QPair")) {
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@
|
|||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include <QtCore/qvector.h>
|
||||
#include <QtCore/qlist.h>
|
||||
|
||||
#ifndef QBYTEARRAYLIST_H
|
||||
#define QBYTEARRAYLIST_H
|
||||
|
|
@ -49,12 +49,12 @@
|
|||
QT_BEGIN_NAMESPACE
|
||||
|
||||
#if !defined(QT_NO_JAVA_STYLE_ITERATORS)
|
||||
typedef QVectorIterator<QByteArray> QByteArrayListIterator;
|
||||
typedef QMutableVectorIterator<QByteArray> QMutableByteArrayListIterator;
|
||||
typedef QListIterator<QByteArray> QByteArrayListIterator;
|
||||
typedef QMutableListIterator<QByteArray> QMutableByteArrayListIterator;
|
||||
#endif
|
||||
|
||||
#ifndef Q_CLANG_QDOC
|
||||
typedef QVector<QByteArray> QByteArrayList;
|
||||
typedef QList<QByteArray> QByteArrayList;
|
||||
|
||||
namespace QtPrivate {
|
||||
QByteArray Q_CORE_EXPORT QByteArrayList_join(const QByteArrayList *that, const char *separator, int separatorLength);
|
||||
|
|
@ -63,14 +63,14 @@ namespace QtPrivate {
|
|||
#endif
|
||||
|
||||
#ifdef Q_CLANG_QDOC
|
||||
class QByteArrayList : public QVector<QByteArray>
|
||||
class QByteArrayList : public QList<QByteArray>
|
||||
#else
|
||||
template <> struct QVectorSpecialMethods<QByteArray>
|
||||
template <> struct QListSpecialMethods<QByteArray>
|
||||
#endif
|
||||
{
|
||||
#ifndef Q_CLANG_QDOC
|
||||
protected:
|
||||
~QVectorSpecialMethods() = default;
|
||||
~QListSpecialMethods() = default;
|
||||
#endif
|
||||
public:
|
||||
inline QByteArray join() const
|
||||
|
|
@ -81,7 +81,7 @@ public:
|
|||
{ return QtPrivate::QByteArrayList_join(self(), &sep, 1); }
|
||||
|
||||
private:
|
||||
typedef QVector<QByteArray> Self;
|
||||
typedef QList<QByteArray> Self;
|
||||
Self *self() { return static_cast<Self *>(this); }
|
||||
const Self *self() const { return static_cast<const Self *>(this); }
|
||||
};
|
||||
|
|
|
|||
|
|
@ -77,7 +77,6 @@ class QRegularExpressionMatch;
|
|||
class QString;
|
||||
class QStringList;
|
||||
class QStringRef;
|
||||
template <typename T> class QVector;
|
||||
|
||||
namespace QtPrivate {
|
||||
template <bool...B> class BoolList;
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@
|
|||
#define QSTRINGALGORITHMS_H
|
||||
|
||||
#include <QtCore/qnamespace.h>
|
||||
|
||||
#include <QtCore/qcontainerfwd.h>
|
||||
#if 0
|
||||
#pragma qt_class(QStringAlgorithms)
|
||||
#endif
|
||||
|
|
@ -52,7 +52,6 @@ class QByteArray;
|
|||
class QLatin1String;
|
||||
class QStringView;
|
||||
class QChar;
|
||||
template <typename T> class QVector;
|
||||
|
||||
namespace QtPrivate {
|
||||
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@
|
|||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include <QtCore/qvector.h>
|
||||
#include <QtCore/qlist.h>
|
||||
|
||||
#ifndef QSTRINGLIST_H
|
||||
#define QSTRINGLIST_H
|
||||
|
|
@ -53,21 +53,21 @@ QT_BEGIN_NAMESPACE
|
|||
class QRegularExpression;
|
||||
|
||||
#if !defined(QT_NO_JAVA_STYLE_ITERATORS)
|
||||
typedef QVectorIterator<QString> QStringListIterator;
|
||||
typedef QMutableVectorIterator<QString> QMutableStringListIterator;
|
||||
using QStringListIterator = QListIterator<QString>;
|
||||
using QMutableStringListIterator = QMutableListIterator<QString>;
|
||||
#endif
|
||||
|
||||
class QStringList;
|
||||
|
||||
#ifdef Q_QDOC
|
||||
class QStringList : public QVector<QString>
|
||||
class QStringList : public QList<QString>
|
||||
#else
|
||||
template <> struct QVectorSpecialMethods<QString>
|
||||
template <> struct QListSpecialMethods<QString>
|
||||
#endif
|
||||
{
|
||||
#ifndef Q_QDOC
|
||||
protected:
|
||||
~QVectorSpecialMethods() = default;
|
||||
~QListSpecialMethods() = default;
|
||||
#endif
|
||||
public:
|
||||
inline void sort(Qt::CaseSensitivity cs = Qt::CaseSensitive);
|
||||
|
|
@ -101,23 +101,23 @@ private:
|
|||
};
|
||||
|
||||
// ### Qt6: check if there's a better way
|
||||
class QStringList : public QVector<QString>
|
||||
class QStringList : public QList<QString>
|
||||
{
|
||||
#endif
|
||||
public:
|
||||
inline QStringList() noexcept { }
|
||||
inline explicit QStringList(const QString &i) { append(i); }
|
||||
inline QStringList(const QVector<QString> &l) : QVector<QString>(l) { }
|
||||
inline QStringList(QVector<QString> &&l) noexcept : QVector<QString>(std::move(l)) { }
|
||||
inline QStringList(std::initializer_list<QString> args) : QVector<QString>(args) { }
|
||||
inline QStringList(const QList<QString> &l) : QList<QString>(l) { }
|
||||
inline QStringList(QList<QString> &&l) noexcept : QList<QString>(std::move(l)) { }
|
||||
inline QStringList(std::initializer_list<QString> args) : QList<QString>(args) { }
|
||||
template <typename InputIterator, QtPrivate::IfIsInputIterator<InputIterator> = true>
|
||||
inline QStringList(InputIterator first, InputIterator last)
|
||||
: QVector<QString>(first, last) { }
|
||||
: QList<QString>(first, last) { }
|
||||
|
||||
QStringList &operator=(const QVector<QString> &other)
|
||||
{ QVector<QString>::operator=(other); return *this; }
|
||||
QStringList &operator=(QVector<QString> &&other) noexcept
|
||||
{ QVector<QString>::operator=(std::move(other)); return *this; }
|
||||
QStringList &operator=(const QList<QString> &other)
|
||||
{ QList<QString>::operator=(other); return *this; }
|
||||
QStringList &operator=(QList<QString> &&other) noexcept
|
||||
{ QList<QString>::operator=(std::move(other)); return *this; }
|
||||
|
||||
#if QT_STRINGVIEW_LEVEL < 2
|
||||
inline bool contains(const QString &str, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
|
||||
|
|
@ -131,7 +131,7 @@ public:
|
|||
{ append(str); return *this; }
|
||||
inline QStringList &operator<<(const QStringList &l)
|
||||
{ *this += l; return *this; }
|
||||
inline QStringList &operator<<(const QVector<QString> &l)
|
||||
inline QStringList &operator<<(const QList<QString> &l)
|
||||
{ *this += l; return *this; }
|
||||
|
||||
inline int indexOf(QStringView str, int from = 0) const;
|
||||
|
|
@ -145,16 +145,16 @@ public:
|
|||
inline int lastIndexOf(const QRegularExpression &re, int from = -1) const;
|
||||
#endif // QT_CONFIG(regularexpression)
|
||||
|
||||
using QVector<QString>::indexOf;
|
||||
using QVector<QString>::lastIndexOf;
|
||||
using QList<QString>::indexOf;
|
||||
using QList<QString>::lastIndexOf;
|
||||
};
|
||||
|
||||
Q_DECLARE_TYPEINFO(QStringList, Q_MOVABLE_TYPE);
|
||||
|
||||
#ifndef Q_QDOC
|
||||
inline QStringList *QVectorSpecialMethods<QString>::self()
|
||||
inline QStringList *QListSpecialMethods<QString>::self()
|
||||
{ return static_cast<QStringList *>(this); }
|
||||
inline const QStringList *QVectorSpecialMethods<QString>::self() const
|
||||
inline const QStringList *QListSpecialMethods<QString>::self() const
|
||||
{ return static_cast<const QStringList *>(this); }
|
||||
|
||||
namespace QtPrivate {
|
||||
|
|
@ -190,45 +190,45 @@ namespace QtPrivate {
|
|||
#endif // QT_CONFIG(regularexpression)
|
||||
}
|
||||
|
||||
inline void QVectorSpecialMethods<QString>::sort(Qt::CaseSensitivity cs)
|
||||
inline void QListSpecialMethods<QString>::sort(Qt::CaseSensitivity cs)
|
||||
{
|
||||
QtPrivate::QStringList_sort(self(), cs);
|
||||
}
|
||||
|
||||
inline int QVectorSpecialMethods<QString>::removeDuplicates()
|
||||
inline int QListSpecialMethods<QString>::removeDuplicates()
|
||||
{
|
||||
return QtPrivate::QStringList_removeDuplicates(self());
|
||||
}
|
||||
|
||||
#if QT_STRINGVIEW_LEVEL < 2
|
||||
inline QString QVectorSpecialMethods<QString>::join(const QString &sep) const
|
||||
inline QString QListSpecialMethods<QString>::join(const QString &sep) const
|
||||
{
|
||||
return QtPrivate::QStringList_join(self(), sep.constData(), sep.length());
|
||||
}
|
||||
#endif
|
||||
|
||||
inline QString QVectorSpecialMethods<QString>::join(QStringView sep) const
|
||||
inline QString QListSpecialMethods<QString>::join(QStringView sep) const
|
||||
{
|
||||
return QtPrivate::QStringList_join(self(), sep);
|
||||
}
|
||||
|
||||
QString QVectorSpecialMethods<QString>::join(QLatin1String sep) const
|
||||
QString QListSpecialMethods<QString>::join(QLatin1String sep) const
|
||||
{
|
||||
return QtPrivate::QStringList_join(*self(), sep);
|
||||
}
|
||||
|
||||
inline QString QVectorSpecialMethods<QString>::join(QChar sep) const
|
||||
inline QString QListSpecialMethods<QString>::join(QChar sep) const
|
||||
{
|
||||
return QtPrivate::QStringList_join(self(), &sep, 1);
|
||||
}
|
||||
|
||||
inline QStringList QVectorSpecialMethods<QString>::filter(QStringView str, Qt::CaseSensitivity cs) const
|
||||
inline QStringList QListSpecialMethods<QString>::filter(QStringView str, Qt::CaseSensitivity cs) const
|
||||
{
|
||||
return QtPrivate::QStringList_filter(self(), str, cs);
|
||||
}
|
||||
|
||||
#if QT_STRINGVIEW_LEVEL < 2
|
||||
inline QStringList QVectorSpecialMethods<QString>::filter(const QString &str, Qt::CaseSensitivity cs) const
|
||||
inline QStringList QListSpecialMethods<QString>::filter(const QString &str, Qt::CaseSensitivity cs) const
|
||||
{
|
||||
return QtPrivate::QStringList_filter(self(), str, cs);
|
||||
}
|
||||
|
|
@ -251,33 +251,33 @@ inline bool QStringList::contains(QStringView str, Qt::CaseSensitivity cs) const
|
|||
return QtPrivate::QStringList_contains(this, str, cs);
|
||||
}
|
||||
|
||||
inline QStringList &QVectorSpecialMethods<QString>::replaceInStrings(QStringView before, QStringView after, Qt::CaseSensitivity cs)
|
||||
inline QStringList &QListSpecialMethods<QString>::replaceInStrings(QStringView before, QStringView after, Qt::CaseSensitivity cs)
|
||||
{
|
||||
QtPrivate::QStringList_replaceInStrings(self(), before, after, cs);
|
||||
return *self();
|
||||
}
|
||||
|
||||
#if QT_STRINGVIEW_LEVEL < 2
|
||||
inline QStringList &QVectorSpecialMethods<QString>::replaceInStrings(const QString &before, const QString &after, Qt::CaseSensitivity cs)
|
||||
inline QStringList &QListSpecialMethods<QString>::replaceInStrings(const QString &before, const QString &after, Qt::CaseSensitivity cs)
|
||||
{
|
||||
QtPrivate::QStringList_replaceInStrings(self(), before, after, cs);
|
||||
return *self();
|
||||
}
|
||||
|
||||
inline QStringList &QVectorSpecialMethods<QString>::replaceInStrings(QStringView before, const QString &after, Qt::CaseSensitivity cs)
|
||||
inline QStringList &QListSpecialMethods<QString>::replaceInStrings(QStringView before, const QString &after, Qt::CaseSensitivity cs)
|
||||
{
|
||||
QtPrivate::QStringList_replaceInStrings(self(), before, qToStringViewIgnoringNull(after), cs);
|
||||
return *self();
|
||||
}
|
||||
|
||||
inline QStringList &QVectorSpecialMethods<QString>::replaceInStrings(const QString &before, QStringView after, Qt::CaseSensitivity cs)
|
||||
inline QStringList &QListSpecialMethods<QString>::replaceInStrings(const QString &before, QStringView after, Qt::CaseSensitivity cs)
|
||||
{
|
||||
QtPrivate::QStringList_replaceInStrings(self(), QStringView(before), after, cs);
|
||||
return *self();
|
||||
}
|
||||
#endif
|
||||
|
||||
inline QStringList operator+(const QVector<QString> &one, const QStringList &other)
|
||||
inline QStringList operator+(const QList<QString> &one, const QStringList &other)
|
||||
{
|
||||
QStringList n = one;
|
||||
n += other;
|
||||
|
|
@ -305,13 +305,13 @@ inline int QStringList::lastIndexOf(QLatin1String string, int from) const
|
|||
}
|
||||
|
||||
#if QT_CONFIG(regularexpression)
|
||||
inline QStringList &QVectorSpecialMethods<QString>::replaceInStrings(const QRegularExpression &rx, const QString &after)
|
||||
inline QStringList &QListSpecialMethods<QString>::replaceInStrings(const QRegularExpression &rx, const QString &after)
|
||||
{
|
||||
QtPrivate::QStringList_replaceInStrings(self(), rx, after);
|
||||
return *self();
|
||||
}
|
||||
|
||||
inline QStringList QVectorSpecialMethods<QString>::filter(const QRegularExpression &rx) const
|
||||
inline QStringList QListSpecialMethods<QString>::filter(const QRegularExpression &rx) const
|
||||
{
|
||||
return QtPrivate::QStringList_filter(self(), rx);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -40,11 +40,11 @@
|
|||
#define QSTRINGTOKENIZER_H
|
||||
|
||||
#include <QtCore/qnamespace.h>
|
||||
#include <QtCore/qcontainerfwd.h>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
template <typename, typename> class QStringBuilder;
|
||||
template <typename> class QVector;
|
||||
|
||||
#if defined(Q_QDOC) || 1 || (defined(__cpp_range_based_for) && __cpp_range_based_for >= 201603)
|
||||
# define Q_STRINGTOKENIZER_USE_SENTINEL
|
||||
|
|
|
|||
|
|
@ -56,8 +56,8 @@ template <class T> class QQueue;
|
|||
template <class T> class QSet;
|
||||
template <class T> class QStack;
|
||||
template<class T, qsizetype Prealloc = 256> class QVarLengthArray;
|
||||
template <class T> class QVector;
|
||||
template<typename T> using QList = QVector<T>;
|
||||
template <class T> class QList;
|
||||
template<typename T> using QVector = QList<T>;
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
|
|
|
|||
|
|
@ -50,8 +50,8 @@ QT_BEGIN_NAMESPACE
|
|||
/*
|
||||
### Qt 5:
|
||||
### This needs to be removed for next releases of Qt. It is a workaround for vc++ because
|
||||
### Qt exports QPolygon and QPolygonF that inherit QVector<QPoint> and
|
||||
### QVector<QPointF> respectively.
|
||||
### Qt exports QPolygon and QPolygonF that inherit QList<QPoint> and
|
||||
### QList<QPointF> respectively.
|
||||
*/
|
||||
|
||||
#if defined(Q_CC_MSVC) && defined(QT_BUILD_CORE_LIB)
|
||||
|
|
@ -59,8 +59,8 @@ QT_BEGIN_INCLUDE_NAMESPACE
|
|||
#include <QtCore/qpoint.h>
|
||||
QT_END_INCLUDE_NAMESPACE
|
||||
|
||||
template class Q_CORE_EXPORT QVector<QPointF>;
|
||||
template class Q_CORE_EXPORT QVector<QPoint>;
|
||||
template class Q_CORE_EXPORT QList<QPointF>;
|
||||
template class Q_CORE_EXPORT QList<QPoint>;
|
||||
#endif
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2016 The Qt Company Ltd.
|
||||
** Copyright (C) 2020 The Qt Company Ltd.
|
||||
** Copyright (C) 2019 Intel Corporation
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of the QtCore module of the Qt Toolkit.
|
||||
|
|
@ -40,17 +41,756 @@
|
|||
#ifndef QLIST_H
|
||||
#define QLIST_H
|
||||
|
||||
#include <QtCore/qvector.h>
|
||||
#include <QtCore/qcontainerfwd.h>
|
||||
#include <QtCore/qarraydatapointer.h>
|
||||
#include <QtCore/qnamespace.h>
|
||||
#include <QtCore/qhashfunctions.h>
|
||||
#include <QtCore/qiterator.h>
|
||||
|
||||
#include <functional>
|
||||
#include <limits>
|
||||
#include <initializer_list>
|
||||
#include <type_traits>
|
||||
|
||||
#if !defined(QT_NO_JAVA_STYLE_ITERATORS)
|
||||
QT_BEGIN_NAMESPACE
|
||||
template<typename T>
|
||||
using QMutableListIterator = QMutableVectorIterator<T>;
|
||||
template<typename T>
|
||||
using QListIterator = QVectorIterator<T>;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
namespace QtPrivate {
|
||||
template <typename V, typename U> int indexOf(const QList<V> &list, const U &u, int from);
|
||||
template <typename V, typename U> int lastIndexOf(const QList<V> &list, const U &u, int from);
|
||||
}
|
||||
|
||||
template <typename T> struct QListSpecialMethods
|
||||
{
|
||||
protected:
|
||||
~QListSpecialMethods() = default;
|
||||
};
|
||||
template <> struct QListSpecialMethods<QByteArray>;
|
||||
template <> struct QListSpecialMethods<QString>;
|
||||
|
||||
template <typename T>
|
||||
class QList
|
||||
#ifndef Q_QDOC
|
||||
: public QListSpecialMethods<T>
|
||||
#endif
|
||||
{
|
||||
typedef QTypedArrayData<T> Data;
|
||||
typedef QArrayDataOps<T> DataOps;
|
||||
typedef QArrayDataPointer<T> DataPointer;
|
||||
class DisableRValueRefs {};
|
||||
|
||||
DataPointer d;
|
||||
|
||||
template <typename V, typename U> friend int QtPrivate::indexOf(const QList<V> &list, const U &u, int from);
|
||||
template <typename V, typename U> friend int QtPrivate::lastIndexOf(const QList<V> &list, const U &u, int from);
|
||||
|
||||
public:
|
||||
typedef T Type;
|
||||
typedef T value_type;
|
||||
typedef value_type *pointer;
|
||||
typedef const value_type *const_pointer;
|
||||
typedef value_type &reference;
|
||||
typedef const value_type &const_reference;
|
||||
typedef int size_type;
|
||||
typedef qptrdiff difference_type;
|
||||
typedef typename Data::iterator iterator;
|
||||
typedef typename Data::const_iterator const_iterator;
|
||||
typedef iterator Iterator;
|
||||
typedef const_iterator ConstIterator;
|
||||
typedef std::reverse_iterator<iterator> reverse_iterator;
|
||||
typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
|
||||
typedef typename DataPointer::parameter_type parameter_type;
|
||||
using rvalue_ref = typename std::conditional<DataPointer::pass_parameter_by_value, DisableRValueRefs, T &&>::type;
|
||||
|
||||
private:
|
||||
void resize_internal(int i, Qt::Initialization);
|
||||
bool isValidIterator(const_iterator i) const
|
||||
{
|
||||
const std::less<const T*> less = {};
|
||||
return !less(d->end(), i) && !less(i, d->begin());
|
||||
}
|
||||
public:
|
||||
QList(DataPointer dd) noexcept
|
||||
: d(dd)
|
||||
{
|
||||
}
|
||||
|
||||
public:
|
||||
constexpr inline QList() noexcept { }
|
||||
explicit QList(int size)
|
||||
: d(Data::allocate(size))
|
||||
{
|
||||
if (size)
|
||||
d->appendInitialize(size);
|
||||
}
|
||||
QList(int size, const T &t)
|
||||
: d(Data::allocate(size))
|
||||
{
|
||||
if (size)
|
||||
d->copyAppend(size, t);
|
||||
}
|
||||
|
||||
inline QList(const QList<T> &other) noexcept : d(other.d) {}
|
||||
QList(QList<T> &&other) noexcept : d(std::move(other.d)) {}
|
||||
inline QList(std::initializer_list<T> args)
|
||||
: d(Data::allocate(args.size()))
|
||||
{
|
||||
if (args.size())
|
||||
d->copyAppend(args.begin(), args.end());
|
||||
}
|
||||
|
||||
~QList() /*noexcept(std::is_nothrow_destructible<T>::value)*/ {}
|
||||
QList<T> &operator=(const QList<T> &other) { d = other.d; return *this; }
|
||||
QList &operator=(QList &&other) noexcept(std::is_nothrow_destructible<T>::value)
|
||||
{
|
||||
d = std::move(other.d);
|
||||
return *this;
|
||||
}
|
||||
QList<T> &operator=(std::initializer_list<T> args)
|
||||
{
|
||||
d = DataPointer(Data::allocate(args.size()));
|
||||
if (args.size())
|
||||
d->copyAppend(args.begin(), args.end());
|
||||
return *this;
|
||||
}
|
||||
template <typename InputIterator, QtPrivate::IfIsForwardIterator<InputIterator> = true>
|
||||
QList(InputIterator i1, InputIterator i2)
|
||||
: d(Data::allocate(std::distance(i1, i2)))
|
||||
{
|
||||
if (std::distance(i1, i2))
|
||||
d->copyAppend(i1, i2);
|
||||
}
|
||||
|
||||
template <typename InputIterator, QtPrivate::IfIsNotForwardIterator<InputIterator> = true>
|
||||
QList(InputIterator i1, InputIterator i2)
|
||||
: QList()
|
||||
{
|
||||
QtPrivate::reserveIfForwardIterator(this, i1, i2);
|
||||
std::copy(i1, i2, std::back_inserter(*this));
|
||||
}
|
||||
|
||||
void swap(QList<T> &other) noexcept { qSwap(d, other.d); }
|
||||
|
||||
friend bool operator==(const QList &l, const QList &r)
|
||||
{
|
||||
if (l.size() != r.size())
|
||||
return false;
|
||||
if (l.begin() == r.begin())
|
||||
return true;
|
||||
|
||||
// do element-by-element comparison
|
||||
return l.d->compare(l.begin(), r.begin(), l.size());
|
||||
}
|
||||
friend bool operator!=(const QList &l, const QList &r)
|
||||
{
|
||||
return !(l == r);
|
||||
}
|
||||
|
||||
int size() const noexcept { return int(d->size); }
|
||||
int count() const noexcept { return size(); }
|
||||
int length() const noexcept { return size(); }
|
||||
|
||||
inline bool isEmpty() const noexcept { return d->size == 0; }
|
||||
|
||||
void resize(int size)
|
||||
{
|
||||
resize_internal(size, Qt::Uninitialized);
|
||||
if (size > this->size())
|
||||
d->appendInitialize(size);
|
||||
}
|
||||
void resize(int size, parameter_type c)
|
||||
{
|
||||
resize_internal(size, Qt::Uninitialized);
|
||||
if (size > this->size())
|
||||
d->copyAppend(size - this->size(), c);
|
||||
}
|
||||
|
||||
inline int capacity() const { return int(d->constAllocatedCapacity()); }
|
||||
void reserve(int size);
|
||||
inline void squeeze();
|
||||
|
||||
void detach() { d.detach(); }
|
||||
bool isDetached() const noexcept { return !d->isShared(); }
|
||||
|
||||
inline bool isSharedWith(const QList<T> &other) const { return d == other.d; }
|
||||
|
||||
pointer data() { detach(); return d->data(); }
|
||||
const_pointer data() const noexcept { return d->data(); }
|
||||
const_pointer constData() const noexcept { return d->data(); }
|
||||
void clear() {
|
||||
if (!size())
|
||||
return;
|
||||
if (d->needsDetach()) {
|
||||
// must allocate memory
|
||||
DataPointer detached(Data::allocate(d.allocatedCapacity(), d->detachFlags()));
|
||||
d.swap(detached);
|
||||
} else {
|
||||
d->truncate(0);
|
||||
}
|
||||
}
|
||||
|
||||
const_reference at(int i) const noexcept
|
||||
{
|
||||
Q_ASSERT_X(size_t(i) < size_t(d->size), "QList::at", "index out of range");
|
||||
return data()[i];
|
||||
}
|
||||
reference operator[](int i)
|
||||
{
|
||||
Q_ASSERT_X(size_t(i) < size_t(d->size), "QList::operator[]", "index out of range");
|
||||
detach();
|
||||
return data()[i];
|
||||
}
|
||||
const_reference operator[](int i) const noexcept { return at(i); }
|
||||
void append(const_reference t)
|
||||
{ append(const_iterator(std::addressof(t)), const_iterator(std::addressof(t)) + 1); }
|
||||
void append(const_iterator i1, const_iterator i2);
|
||||
void append(rvalue_ref t) { emplaceBack(std::move(t)); }
|
||||
void append(const QList<T> &l) { append(l.constBegin(), l.constEnd()); }
|
||||
void prepend(rvalue_ref t);
|
||||
void prepend(const T &t);
|
||||
|
||||
template <typename ...Args>
|
||||
reference emplaceBack(Args&&... args) { return *emplace(count(), std::forward<Args>(args)...); }
|
||||
|
||||
iterator insert(int i, parameter_type t)
|
||||
{ return insert(i, 1, t); }
|
||||
iterator insert(int i, int n, parameter_type t);
|
||||
iterator insert(const_iterator before, parameter_type t)
|
||||
{
|
||||
Q_ASSERT_X(isValidIterator(before), "QList::insert", "The specified iterator argument 'before' is invalid");
|
||||
return insert(before, 1, t);
|
||||
}
|
||||
iterator insert(const_iterator before, int n, parameter_type t)
|
||||
{
|
||||
Q_ASSERT_X(isValidIterator(before), "QList::insert", "The specified iterator argument 'before' is invalid");
|
||||
return insert(std::distance(constBegin(), before), n, t);
|
||||
}
|
||||
iterator insert(const_iterator before, rvalue_ref t)
|
||||
{
|
||||
Q_ASSERT_X(isValidIterator(before), "QList::insert", "The specified iterator argument 'before' is invalid");
|
||||
return insert(std::distance(constBegin(), before), std::move(t));
|
||||
}
|
||||
iterator insert(int i, rvalue_ref t) { return emplace(i, std::move(t)); }
|
||||
|
||||
template <typename ...Args>
|
||||
iterator emplace(const_iterator before, Args&&... args)
|
||||
{
|
||||
Q_ASSERT_X(isValidIterator(before), "QList::emplace", "The specified iterator argument 'before' is invalid");
|
||||
return emplace(std::distance(constBegin(), before), std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
template <typename ...Args>
|
||||
iterator emplace(int i, Args&&... args);
|
||||
#if 0
|
||||
template< class InputIt >
|
||||
iterator insert( const_iterator pos, InputIt first, InputIt last );
|
||||
iterator insert( const_iterator pos, std::initializer_list<T> ilist );
|
||||
#endif
|
||||
void replace(int i, const T &t)
|
||||
{
|
||||
Q_ASSERT_X(i >= 0 && i < d->size, "QList<T>::replace", "index out of range");
|
||||
const T copy(t);
|
||||
data()[i] = copy;
|
||||
}
|
||||
void replace(int i, rvalue_ref t)
|
||||
{
|
||||
Q_ASSERT_X(i >= 0 && i < d->size, "QList<T>::replace", "index out of range");
|
||||
const T copy(std::move(t));
|
||||
data()[i] = std::move(copy);
|
||||
}
|
||||
|
||||
void remove(int i, int n = 1);
|
||||
void removeFirst() { Q_ASSERT(!isEmpty()); remove(0); }
|
||||
void removeLast() { Q_ASSERT(!isEmpty()); remove(size() - 1); }
|
||||
value_type takeFirst() { Q_ASSERT(!isEmpty()); value_type v = std::move(first()); remove(0); return v; }
|
||||
value_type takeLast() { Q_ASSERT(!isEmpty()); value_type v = std::move(last()); remove(size() - 1); return v; }
|
||||
|
||||
QList<T> &fill(parameter_type t, int size = -1);
|
||||
|
||||
int indexOf(const T &t, int from = 0) const noexcept;
|
||||
int lastIndexOf(const T &t, int from = -1) const noexcept;
|
||||
bool contains(const T &t) const noexcept
|
||||
{
|
||||
return indexOf(t) != -1;
|
||||
}
|
||||
int count(const T &t) const noexcept
|
||||
{
|
||||
return int(std::count(&*cbegin(), &*cend(), t));
|
||||
}
|
||||
|
||||
// QList compatibility
|
||||
void removeAt(int i) { remove(i); }
|
||||
int removeAll(const T &t)
|
||||
{
|
||||
const const_iterator ce = this->cend(), cit = std::find(this->cbegin(), ce, t);
|
||||
if (cit == ce)
|
||||
return 0;
|
||||
int index = cit - this->cbegin();
|
||||
// next operation detaches, so ce, cit, t may become invalidated:
|
||||
const T tCopy = t;
|
||||
const iterator e = end(), it = std::remove(begin() + index, e, tCopy);
|
||||
const int result = std::distance(it, e);
|
||||
erase(it, e);
|
||||
return result;
|
||||
}
|
||||
bool removeOne(const T &t)
|
||||
{
|
||||
const int i = indexOf(t);
|
||||
if (i < 0)
|
||||
return false;
|
||||
remove(i);
|
||||
return true;
|
||||
}
|
||||
T takeAt(int i) { T t = std::move((*this)[i]); remove(i); return t; }
|
||||
void move(int from, int to)
|
||||
{
|
||||
Q_ASSERT_X(from >= 0 && from < size(), "QList::move(int,int)", "'from' is out-of-range");
|
||||
Q_ASSERT_X(to >= 0 && to < size(), "QList::move(int,int)", "'to' is out-of-range");
|
||||
if (from == to) // don't detach when no-op
|
||||
return;
|
||||
detach();
|
||||
T * const b = d->begin();
|
||||
if (from < to)
|
||||
std::rotate(b + from, b + from + 1, b + to + 1);
|
||||
else
|
||||
std::rotate(b + to, b + from, b + from + 1);
|
||||
}
|
||||
|
||||
// STL-style
|
||||
iterator begin() { detach(); return d->begin(); }
|
||||
iterator end() { detach(); return d->end(); }
|
||||
|
||||
const_iterator begin() const noexcept { return d->constBegin(); }
|
||||
const_iterator end() const noexcept { return d->constEnd(); }
|
||||
const_iterator cbegin() const noexcept { return d->constBegin(); }
|
||||
const_iterator cend() const noexcept { return d->constEnd(); }
|
||||
const_iterator constBegin() const noexcept { return d->constBegin(); }
|
||||
const_iterator constEnd() const noexcept { return d->constEnd(); }
|
||||
reverse_iterator rbegin() { return reverse_iterator(end()); }
|
||||
reverse_iterator rend() { return reverse_iterator(begin()); }
|
||||
const_reverse_iterator rbegin() const noexcept { return const_reverse_iterator(end()); }
|
||||
const_reverse_iterator rend() const noexcept { return const_reverse_iterator(begin()); }
|
||||
const_reverse_iterator crbegin() const noexcept { return const_reverse_iterator(end()); }
|
||||
const_reverse_iterator crend() const noexcept { return const_reverse_iterator(begin()); }
|
||||
|
||||
iterator erase(const_iterator begin, const_iterator end);
|
||||
inline iterator erase(const_iterator pos) { return erase(pos, pos+1); }
|
||||
|
||||
// more Qt
|
||||
inline T& first() { Q_ASSERT(!isEmpty()); return *begin(); }
|
||||
inline const T &first() const { Q_ASSERT(!isEmpty()); return *begin(); }
|
||||
inline const T &constFirst() const { Q_ASSERT(!isEmpty()); return *begin(); }
|
||||
inline T& last() { Q_ASSERT(!isEmpty()); return *(end()-1); }
|
||||
inline const T &last() const { Q_ASSERT(!isEmpty()); return *(end()-1); }
|
||||
inline const T &constLast() const { Q_ASSERT(!isEmpty()); return *(end()-1); }
|
||||
inline bool startsWith(const T &t) const { return !isEmpty() && first() == t; }
|
||||
inline bool endsWith(const T &t) const { return !isEmpty() && last() == t; }
|
||||
QList<T> mid(int pos, int len = -1) const;
|
||||
|
||||
T value(int i) const { return value(i, T()); }
|
||||
T value(int i, const T &defaultValue) const;
|
||||
|
||||
void swapItemsAt(int i, int j) {
|
||||
Q_ASSERT_X(i >= 0 && i < size() && j >= 0 && j < size(),
|
||||
"QList<T>::swap", "index out of range");
|
||||
detach();
|
||||
qSwap(d->begin()[i], d->begin()[j]);
|
||||
}
|
||||
|
||||
// STL compatibility
|
||||
inline void push_back(const T &t) { append(t); }
|
||||
void push_back(rvalue_ref t) { append(std::move(t)); }
|
||||
void push_front(rvalue_ref t) { prepend(std::move(t)); }
|
||||
inline void push_front(const T &t) { prepend(t); }
|
||||
void pop_back() { removeLast(); }
|
||||
void pop_front() { removeFirst(); }
|
||||
|
||||
template <typename ...Args>
|
||||
reference emplace_back(Args&&... args) { return emplaceBack(std::forward<Args>(args)...); }
|
||||
|
||||
inline bool empty() const
|
||||
{ return d->size == 0; }
|
||||
inline reference front() { return first(); }
|
||||
inline const_reference front() const { return first(); }
|
||||
inline reference back() { return last(); }
|
||||
inline const_reference back() const { return last(); }
|
||||
void shrink_to_fit() { squeeze(); }
|
||||
|
||||
// comfort
|
||||
QList<T> &operator+=(const QList<T> &l) { append(l.cbegin(), l.cend()); return *this; }
|
||||
inline QList<T> operator+(const QList<T> &l) const
|
||||
{ QList n = *this; n += l; return n; }
|
||||
inline QList<T> &operator+=(const T &t)
|
||||
{ append(t); return *this; }
|
||||
inline QList<T> &operator<< (const T &t)
|
||||
{ append(t); return *this; }
|
||||
inline QList<T> &operator<<(const QList<T> &l)
|
||||
{ *this += l; return *this; }
|
||||
inline QList<T> &operator+=(rvalue_ref t)
|
||||
{ append(std::move(t)); return *this; }
|
||||
inline QList<T> &operator<<(rvalue_ref t)
|
||||
{ append(std::move(t)); return *this; }
|
||||
|
||||
// Consider deprecating in 6.4 or later
|
||||
static QList<T> fromList(const QList<T> &list) { return list; }
|
||||
QList<T> toList() const { return *this; }
|
||||
|
||||
static inline QList<T> fromVector(const QList<T> &vector) { return vector; }
|
||||
inline QList<T> toVector() const { return *this; }
|
||||
};
|
||||
|
||||
#if defined(__cpp_deduction_guides) && __cpp_deduction_guides >= 201606
|
||||
template <typename InputIterator,
|
||||
typename ValueType = typename std::iterator_traits<InputIterator>::value_type,
|
||||
QtPrivate::IfIsInputIterator<InputIterator> = true>
|
||||
QList(InputIterator, InputIterator) -> QList<ValueType>;
|
||||
#endif
|
||||
|
||||
template <typename T>
|
||||
inline void QList<T>::resize_internal(int newSize, Qt::Initialization)
|
||||
{
|
||||
Q_ASSERT(newSize >= 0);
|
||||
|
||||
if (d->needsDetach() || newSize > capacity()) {
|
||||
// must allocate memory
|
||||
DataPointer detached(Data::allocate(d->detachCapacity(newSize),
|
||||
d->detachFlags()));
|
||||
if (size() && newSize) {
|
||||
detached->copyAppend(constBegin(), constBegin() + qMin(newSize, size()));
|
||||
}
|
||||
d.swap(detached);
|
||||
}
|
||||
|
||||
if (newSize < size())
|
||||
d->truncate(newSize);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void QList<T>::reserve(int asize)
|
||||
{
|
||||
// capacity() == 0 for immutable data, so this will force a detaching below
|
||||
if (asize <= capacity()) {
|
||||
if (d->flags() & Data::CapacityReserved)
|
||||
return; // already reserved, don't shrink
|
||||
if (!d->isShared()) {
|
||||
// accept current allocation, don't shrink
|
||||
d->flags() |= Data::CapacityReserved;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
DataPointer detached(Data::allocate(qMax(asize, size()),
|
||||
d->detachFlags() | Data::CapacityReserved));
|
||||
detached->copyAppend(constBegin(), constEnd());
|
||||
d.swap(detached);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline void QList<T>::squeeze()
|
||||
{
|
||||
if (d->needsDetach() || size() != capacity()) {
|
||||
// must allocate memory
|
||||
DataPointer detached(Data::allocate(size(), d->detachFlags() & ~Data::CapacityReserved));
|
||||
if (size()) {
|
||||
detached->copyAppend(constBegin(), constEnd());
|
||||
}
|
||||
d.swap(detached);
|
||||
}
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline void QList<T>::remove(int i, int n)
|
||||
{
|
||||
Q_ASSERT_X(size_t(i) + size_t(n) <= size_t(d->size), "QList::remove", "index out of range");
|
||||
Q_ASSERT_X(n >= 0, "QList::remove", "invalid count");
|
||||
|
||||
if (n == 0)
|
||||
return;
|
||||
|
||||
const size_t newSize = size() - n;
|
||||
if (d->needsDetach() ||
|
||||
((d->flags() & Data::CapacityReserved) == 0
|
||||
&& newSize < d->allocatedCapacity()/2)) {
|
||||
// allocate memory
|
||||
DataPointer detached(Data::allocate(d->detachCapacity(newSize),
|
||||
d->detachFlags() & ~(Data::GrowsBackwards | Data::GrowsForward)));
|
||||
const_iterator where = constBegin() + i;
|
||||
if (newSize) {
|
||||
detached->copyAppend(constBegin(), where);
|
||||
detached->copyAppend(where + n, constEnd());
|
||||
}
|
||||
d.swap(detached);
|
||||
} else {
|
||||
// we're detached and we can just move data around
|
||||
d->erase(d->begin() + i, d->begin() + i + n);
|
||||
}
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline void QList<T>::prepend(const T &t)
|
||||
{ insert(0, 1, t); }
|
||||
template <typename T>
|
||||
void QList<T>::prepend(rvalue_ref t)
|
||||
{ insert(0, std::move(t)); }
|
||||
|
||||
template<typename T>
|
||||
inline T QList<T>::value(int i, const T &defaultValue) const
|
||||
{
|
||||
return size_t(i) < size_t(d->size) ? at(i) : defaultValue;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline void QList<T>::append(const_iterator i1, const_iterator i2)
|
||||
{
|
||||
if (i1 == i2)
|
||||
return;
|
||||
const size_t newSize = size() + std::distance(i1, i2);
|
||||
if (d->needsDetach() || newSize > d->allocatedCapacity()) {
|
||||
DataPointer detached(Data::allocate(d->detachCapacity(newSize),
|
||||
d->detachFlags() | Data::GrowsForward));
|
||||
detached->copyAppend(constBegin(), constEnd());
|
||||
detached->copyAppend(i1, i2);
|
||||
d.swap(detached);
|
||||
} else {
|
||||
// we're detached and we can just move data around
|
||||
d->copyAppend(i1, i2);
|
||||
}
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline typename QList<T>::iterator
|
||||
QList<T>::insert(int i, int n, parameter_type t)
|
||||
{
|
||||
Q_ASSERT_X(size_t(i) <= size_t(d->size), "QList<T>::insert", "index out of range");
|
||||
|
||||
// we don't have a quick exit for n == 0
|
||||
// it's not worth wasting CPU cycles for that
|
||||
|
||||
const size_t newSize = size() + n;
|
||||
if (d->needsDetach() || newSize > d->allocatedCapacity()) {
|
||||
typename Data::ArrayOptions flags = d->detachFlags() | Data::GrowsForward;
|
||||
if (size_t(i) <= newSize / 4)
|
||||
flags |= Data::GrowsBackwards;
|
||||
|
||||
DataPointer detached(Data::allocate(d->detachCapacity(newSize), flags));
|
||||
const_iterator where = constBegin() + i;
|
||||
detached->copyAppend(constBegin(), where);
|
||||
detached->copyAppend(n, t);
|
||||
detached->copyAppend(where, constEnd());
|
||||
d.swap(detached);
|
||||
} else {
|
||||
// we're detached and we can just move data around
|
||||
if (i == size()) {
|
||||
d->copyAppend(n, t);
|
||||
} else {
|
||||
T copy(t);
|
||||
d->insert(d.begin() + i, n, copy);
|
||||
}
|
||||
}
|
||||
return d.begin() + i;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
template <typename ...Args>
|
||||
typename QList<T>::iterator
|
||||
QList<T>::emplace(int i, Args&&... args)
|
||||
{
|
||||
Q_ASSERT_X(i >= 0 && i <= d->size, "QList<T>::insert", "index out of range");
|
||||
|
||||
const size_t newSize = size() + 1;
|
||||
if (d->needsDetach() || newSize > d->allocatedCapacity()) {
|
||||
typename Data::ArrayOptions flags = d->detachFlags() | Data::GrowsForward;
|
||||
if (size_t(i) <= newSize / 4)
|
||||
flags |= Data::GrowsBackwards;
|
||||
|
||||
DataPointer detached(Data::allocate(d->detachCapacity(newSize), flags));
|
||||
const_iterator where = constBegin() + i;
|
||||
|
||||
// First, create an element to handle cases, when a user moves
|
||||
// the element from a container to the same container
|
||||
detached->createInPlace(detached.begin() + i, std::forward<Args>(args)...);
|
||||
|
||||
// Then, put the first part of the elements to the new location
|
||||
detached->copyAppend(constBegin(), where);
|
||||
|
||||
// After that, increase the actual size, because we created
|
||||
// one extra element
|
||||
++detached.size;
|
||||
|
||||
// Finally, put the rest of the elements to the new location
|
||||
detached->copyAppend(where, constEnd());
|
||||
|
||||
d.swap(detached);
|
||||
} else {
|
||||
d->emplace(d.begin() + i, std::forward<Args>(args)...);
|
||||
}
|
||||
return d.begin() + i;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
typename QList<T>::iterator QList<T>::erase(const_iterator abegin, const_iterator aend)
|
||||
{
|
||||
Q_ASSERT_X(isValidIterator(abegin), "QList::erase", "The specified iterator argument 'abegin' is invalid");
|
||||
Q_ASSERT_X(isValidIterator(aend), "QList::erase", "The specified iterator argument 'aend' is invalid");
|
||||
Q_ASSERT(aend >= abegin);
|
||||
|
||||
int i = std::distance(d.constBegin(), abegin);
|
||||
int n = std::distance(abegin, aend);
|
||||
remove(i, n);
|
||||
|
||||
return d.begin() + i;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline QList<T> &QList<T>::fill(parameter_type t, int newSize)
|
||||
{
|
||||
if (newSize == -1)
|
||||
newSize = size();
|
||||
if (d->needsDetach() || newSize > capacity()) {
|
||||
// must allocate memory
|
||||
DataPointer detached(Data::allocate(d->detachCapacity(newSize),
|
||||
d->detachFlags()));
|
||||
detached->copyAppend(newSize, t);
|
||||
d.swap(detached);
|
||||
} else {
|
||||
// we're detached
|
||||
const T copy(t);
|
||||
d->assign(d.begin(), d.begin() + qMin(size(), newSize), t);
|
||||
if (newSize > size())
|
||||
d->copyAppend(newSize - size(), copy);
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
namespace QtPrivate {
|
||||
template <typename T, typename U>
|
||||
int indexOf(const QList<T> &vector, const U &u, int from)
|
||||
{
|
||||
if (from < 0)
|
||||
from = qMax(from + vector.size(), 0);
|
||||
if (from < vector.size()) {
|
||||
auto n = vector.begin() + from - 1;
|
||||
auto e = vector.end();
|
||||
while (++n != e)
|
||||
if (*n == u)
|
||||
return int(n - vector.begin());
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
template <typename T, typename U>
|
||||
int lastIndexOf(const QList<T> &vector, const U &u, int from)
|
||||
{
|
||||
if (from < 0)
|
||||
from += vector.d->size;
|
||||
else if (from >= vector.size())
|
||||
from = vector.size() - 1;
|
||||
if (from >= 0) {
|
||||
auto b = vector.begin();
|
||||
auto n = vector.begin() + from + 1;
|
||||
while (n != b) {
|
||||
if (*--n == u)
|
||||
return int(n - b);
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
int QList<T>::indexOf(const T &t, int from) const noexcept
|
||||
{
|
||||
return QtPrivate::indexOf<T, T>(*this, t, from);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
int QList<T>::lastIndexOf(const T &t, int from) const noexcept
|
||||
{
|
||||
return QtPrivate::lastIndexOf(*this, t, from);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline QList<T> QList<T>::mid(int pos, int len) const
|
||||
{
|
||||
qsizetype p = pos;
|
||||
qsizetype l = len;
|
||||
using namespace QtPrivate;
|
||||
switch (QContainerImplHelper::mid(d.size, &p, &l)) {
|
||||
case QContainerImplHelper::Null:
|
||||
case QContainerImplHelper::Empty:
|
||||
return QList();
|
||||
case QContainerImplHelper::Full:
|
||||
return *this;
|
||||
case QContainerImplHelper::Subset:
|
||||
break;
|
||||
}
|
||||
|
||||
// Allocate memory
|
||||
DataPointer copied(Data::allocate(l));
|
||||
copied->copyAppend(constBegin() + p, constBegin() + p + l);
|
||||
return copied;
|
||||
}
|
||||
|
||||
Q_DECLARE_SEQUENTIAL_ITERATOR(List)
|
||||
Q_DECLARE_MUTABLE_SEQUENTIAL_ITERATOR(List)
|
||||
|
||||
template <typename T>
|
||||
size_t qHash(const QList<T> &key, size_t seed = 0)
|
||||
noexcept(noexcept(qHashRange(key.cbegin(), key.cend(), seed)))
|
||||
{
|
||||
return qHashRange(key.cbegin(), key.cend(), seed);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
auto operator<(const QList<T> &lhs, const QList<T> &rhs)
|
||||
noexcept(noexcept(std::lexicographical_compare(lhs.begin(), lhs.end(),
|
||||
rhs.begin(), rhs.end())))
|
||||
-> decltype(std::declval<T>() < std::declval<T>())
|
||||
{
|
||||
return std::lexicographical_compare(lhs.begin(), lhs.end(),
|
||||
rhs.begin(), rhs.end());
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
auto operator>(const QList<T> &lhs, const QList<T> &rhs)
|
||||
noexcept(noexcept(lhs < rhs))
|
||||
-> decltype(lhs < rhs)
|
||||
{
|
||||
return rhs < lhs;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
auto operator<=(const QList<T> &lhs, const QList<T> &rhs)
|
||||
noexcept(noexcept(lhs < rhs))
|
||||
-> decltype(lhs < rhs)
|
||||
{
|
||||
return !(lhs > rhs);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
auto operator>=(const QList<T> &lhs, const QList<T> &rhs)
|
||||
noexcept(noexcept(lhs < rhs))
|
||||
-> decltype(lhs < rhs)
|
||||
{
|
||||
return !(lhs < rhs);
|
||||
}
|
||||
|
||||
/*
|
||||
### Qt 5:
|
||||
### This needs to be removed for next releases of Qt. It is a workaround for vc++ because
|
||||
### Qt exports QPolygon and QPolygonF that inherit QList<QPoint> and
|
||||
### QList<QPointF> respectively.
|
||||
*/
|
||||
|
||||
#if defined(Q_CC_MSVC) && !defined(QT_BUILD_CORE_LIB)
|
||||
QT_BEGIN_INCLUDE_NAMESPACE
|
||||
#include <QtCore/qpoint.h>
|
||||
QT_END_INCLUDE_NAMESPACE
|
||||
extern template class Q_CORE_EXPORT QList<QPointF>;
|
||||
extern template class Q_CORE_EXPORT QList<QPoint>;
|
||||
#endif
|
||||
|
||||
QList<uint> QStringView::toUcs4() const { return QtPrivate::convertToUcs4(*this); }
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#include <QtCore/qbytearraylist.h>
|
||||
#include <QtCore/qstringlist.h>
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load Diff
|
|
@ -1,7 +1,6 @@
|
|||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2016 The Qt Company Ltd.
|
||||
** Copyright (C) 2019 Intel Corporation
|
||||
** Copyright (C) 2020 The Qt Company Ltd.
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of the QtCore module of the Qt Toolkit.
|
||||
|
|
@ -41,758 +40,18 @@
|
|||
#ifndef QVECTOR_H
|
||||
#define QVECTOR_H
|
||||
|
||||
#include <QtCore/qarraydatapointer.h>
|
||||
#include <QtCore/qnamespace.h>
|
||||
#include <QtCore/qhashfunctions.h>
|
||||
#include <QtCore/qiterator.h>
|
||||
|
||||
#include <functional>
|
||||
#include <limits>
|
||||
#include <initializer_list>
|
||||
#include <type_traits>
|
||||
#include <QtCore/qlist.h>
|
||||
#include <QtCore/qcontainerfwd.h>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
namespace QtPrivate {
|
||||
template <typename V, typename U> int indexOf(const QVector<V> &list, const U &u, int from);
|
||||
template <typename V, typename U> int lastIndexOf(const QVector<V> &list, const U &u, int from);
|
||||
}
|
||||
|
||||
template <typename T> struct QVectorSpecialMethods
|
||||
{
|
||||
protected:
|
||||
~QVectorSpecialMethods() = default;
|
||||
};
|
||||
template <> struct QVectorSpecialMethods<QByteArray>;
|
||||
template <> struct QVectorSpecialMethods<QString>;
|
||||
|
||||
template <typename T>
|
||||
class QVector
|
||||
#ifndef Q_QDOC
|
||||
: public QVectorSpecialMethods<T>
|
||||
#endif
|
||||
{
|
||||
typedef QTypedArrayData<T> Data;
|
||||
typedef QArrayDataOps<T> DataOps;
|
||||
typedef QArrayDataPointer<T> DataPointer;
|
||||
class DisableRValueRefs {};
|
||||
|
||||
DataPointer d;
|
||||
|
||||
template <typename V, typename U> friend int QtPrivate::indexOf(const QVector<V> &list, const U &u, int from);
|
||||
template <typename V, typename U> friend int QtPrivate::lastIndexOf(const QVector<V> &list, const U &u, int from);
|
||||
|
||||
public:
|
||||
typedef T Type;
|
||||
typedef T value_type;
|
||||
typedef value_type *pointer;
|
||||
typedef const value_type *const_pointer;
|
||||
typedef value_type &reference;
|
||||
typedef const value_type &const_reference;
|
||||
typedef int size_type;
|
||||
typedef qptrdiff difference_type;
|
||||
typedef typename Data::iterator iterator;
|
||||
typedef typename Data::const_iterator const_iterator;
|
||||
typedef iterator Iterator;
|
||||
typedef const_iterator ConstIterator;
|
||||
typedef std::reverse_iterator<iterator> reverse_iterator;
|
||||
typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
|
||||
typedef typename DataPointer::parameter_type parameter_type;
|
||||
using rvalue_ref = typename std::conditional<DataPointer::pass_parameter_by_value, DisableRValueRefs, T &&>::type;
|
||||
|
||||
private:
|
||||
void resize_internal(int i, Qt::Initialization);
|
||||
bool isValidIterator(const_iterator i) const
|
||||
{
|
||||
const std::less<const T*> less = {};
|
||||
return !less(d->end(), i) && !less(i, d->begin());
|
||||
}
|
||||
public:
|
||||
QVector(DataPointer dd) noexcept
|
||||
: d(dd)
|
||||
{
|
||||
}
|
||||
|
||||
public:
|
||||
constexpr inline QVector() noexcept { }
|
||||
explicit QVector(int size)
|
||||
: d(Data::allocate(size))
|
||||
{
|
||||
if (size)
|
||||
d->appendInitialize(size);
|
||||
}
|
||||
QVector(int size, const T &t)
|
||||
: d(Data::allocate(size))
|
||||
{
|
||||
if (size)
|
||||
d->copyAppend(size, t);
|
||||
}
|
||||
|
||||
inline QVector(const QVector<T> &other) noexcept : d(other.d) {}
|
||||
QVector(QVector<T> &&other) noexcept : d(std::move(other.d)) {}
|
||||
inline QVector(std::initializer_list<T> args)
|
||||
: d(Data::allocate(args.size()))
|
||||
{
|
||||
if (args.size())
|
||||
d->copyAppend(args.begin(), args.end());
|
||||
}
|
||||
|
||||
~QVector() /*noexcept(std::is_nothrow_destructible<T>::value)*/ {}
|
||||
QVector<T> &operator=(const QVector<T> &other) { d = other.d; return *this; }
|
||||
QVector &operator=(QVector &&other) noexcept(std::is_nothrow_destructible<T>::value)
|
||||
{
|
||||
d = std::move(other.d);
|
||||
return *this;
|
||||
}
|
||||
QVector<T> &operator=(std::initializer_list<T> args)
|
||||
{
|
||||
d = DataPointer(Data::allocate(args.size()));
|
||||
if (args.size())
|
||||
d->copyAppend(args.begin(), args.end());
|
||||
return *this;
|
||||
}
|
||||
template <typename InputIterator, QtPrivate::IfIsForwardIterator<InputIterator> = true>
|
||||
QVector(InputIterator i1, InputIterator i2)
|
||||
: d(Data::allocate(std::distance(i1, i2)))
|
||||
{
|
||||
if (std::distance(i1, i2))
|
||||
d->copyAppend(i1, i2);
|
||||
}
|
||||
|
||||
template <typename InputIterator, QtPrivate::IfIsNotForwardIterator<InputIterator> = true>
|
||||
QVector(InputIterator i1, InputIterator i2)
|
||||
: QVector()
|
||||
{
|
||||
QtPrivate::reserveIfForwardIterator(this, i1, i2);
|
||||
std::copy(i1, i2, std::back_inserter(*this));
|
||||
}
|
||||
|
||||
void swap(QVector<T> &other) noexcept { qSwap(d, other.d); }
|
||||
|
||||
friend bool operator==(const QVector &l, const QVector &r)
|
||||
{
|
||||
if (l.size() != r.size())
|
||||
return false;
|
||||
if (l.begin() == r.begin())
|
||||
return true;
|
||||
|
||||
// do element-by-element comparison
|
||||
return l.d->compare(l.begin(), r.begin(), l.size());
|
||||
}
|
||||
friend bool operator!=(const QVector &l, const QVector &r)
|
||||
{
|
||||
return !(l == r);
|
||||
}
|
||||
|
||||
int size() const noexcept { return int(d->size); }
|
||||
int count() const noexcept { return size(); }
|
||||
int length() const noexcept { return size(); }
|
||||
|
||||
inline bool isEmpty() const noexcept { return d->size == 0; }
|
||||
|
||||
void resize(int size)
|
||||
{
|
||||
resize_internal(size, Qt::Uninitialized);
|
||||
if (size > this->size())
|
||||
d->appendInitialize(size);
|
||||
}
|
||||
void resize(int size, parameter_type c)
|
||||
{
|
||||
resize_internal(size, Qt::Uninitialized);
|
||||
if (size > this->size())
|
||||
d->copyAppend(size - this->size(), c);
|
||||
}
|
||||
|
||||
inline int capacity() const { return int(d->constAllocatedCapacity()); }
|
||||
void reserve(int size);
|
||||
inline void squeeze();
|
||||
|
||||
void detach() { d.detach(); }
|
||||
bool isDetached() const noexcept { return !d->isShared(); }
|
||||
|
||||
inline bool isSharedWith(const QVector<T> &other) const { return d == other.d; }
|
||||
|
||||
pointer data() { detach(); return d->data(); }
|
||||
const_pointer data() const noexcept { return d->data(); }
|
||||
const_pointer constData() const noexcept { return d->data(); }
|
||||
void clear() {
|
||||
if (!size())
|
||||
return;
|
||||
if (d->needsDetach()) {
|
||||
// must allocate memory
|
||||
DataPointer detached(Data::allocate(d.allocatedCapacity(), d->detachFlags()));
|
||||
d.swap(detached);
|
||||
} else {
|
||||
d->truncate(0);
|
||||
}
|
||||
}
|
||||
|
||||
const_reference at(int i) const noexcept
|
||||
{
|
||||
Q_ASSERT_X(size_t(i) < size_t(d->size), "QVector::at", "index out of range");
|
||||
return data()[i];
|
||||
}
|
||||
reference operator[](int i)
|
||||
{
|
||||
Q_ASSERT_X(size_t(i) < size_t(d->size), "QVector::operator[]", "index out of range");
|
||||
detach();
|
||||
return data()[i];
|
||||
}
|
||||
const_reference operator[](int i) const noexcept { return at(i); }
|
||||
void append(const_reference t)
|
||||
{ append(const_iterator(std::addressof(t)), const_iterator(std::addressof(t)) + 1); }
|
||||
void append(const_iterator i1, const_iterator i2);
|
||||
void append(rvalue_ref t) { emplaceBack(std::move(t)); }
|
||||
void append(const QVector<T> &l) { append(l.constBegin(), l.constEnd()); }
|
||||
void prepend(rvalue_ref t);
|
||||
void prepend(const T &t);
|
||||
|
||||
template <typename ...Args>
|
||||
reference emplaceBack(Args&&... args) { return *emplace(count(), std::forward<Args>(args)...); }
|
||||
|
||||
iterator insert(int i, parameter_type t)
|
||||
{ return insert(i, 1, t); }
|
||||
iterator insert(int i, int n, parameter_type t);
|
||||
iterator insert(const_iterator before, parameter_type t)
|
||||
{
|
||||
Q_ASSERT_X(isValidIterator(before), "QVector::insert", "The specified iterator argument 'before' is invalid");
|
||||
return insert(before, 1, t);
|
||||
}
|
||||
iterator insert(const_iterator before, int n, parameter_type t)
|
||||
{
|
||||
Q_ASSERT_X(isValidIterator(before), "QVector::insert", "The specified iterator argument 'before' is invalid");
|
||||
return insert(std::distance(constBegin(), before), n, t);
|
||||
}
|
||||
iterator insert(const_iterator before, rvalue_ref t)
|
||||
{
|
||||
Q_ASSERT_X(isValidIterator(before), "QVector::insert", "The specified iterator argument 'before' is invalid");
|
||||
return insert(std::distance(constBegin(), before), std::move(t));
|
||||
}
|
||||
iterator insert(int i, rvalue_ref t) { return emplace(i, std::move(t)); }
|
||||
|
||||
template <typename ...Args>
|
||||
iterator emplace(const_iterator before, Args&&... args)
|
||||
{
|
||||
Q_ASSERT_X(isValidIterator(before), "QVector::emplace", "The specified iterator argument 'before' is invalid");
|
||||
return emplace(std::distance(constBegin(), before), std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
template <typename ...Args>
|
||||
iterator emplace(int i, Args&&... args);
|
||||
#if 0
|
||||
template< class InputIt >
|
||||
iterator insert( const_iterator pos, InputIt first, InputIt last );
|
||||
iterator insert( const_iterator pos, std::initializer_list<T> ilist );
|
||||
#endif
|
||||
void replace(int i, const T &t)
|
||||
{
|
||||
Q_ASSERT_X(i >= 0 && i < d->size, "QVector<T>::replace", "index out of range");
|
||||
const T copy(t);
|
||||
data()[i] = copy;
|
||||
}
|
||||
void replace(int i, rvalue_ref t)
|
||||
{
|
||||
Q_ASSERT_X(i >= 0 && i < d->size, "QVector<T>::replace", "index out of range");
|
||||
const T copy(std::move(t));
|
||||
data()[i] = std::move(copy);
|
||||
}
|
||||
|
||||
void remove(int i, int n = 1);
|
||||
void removeFirst() { Q_ASSERT(!isEmpty()); remove(0); }
|
||||
void removeLast() { Q_ASSERT(!isEmpty()); remove(size() - 1); }
|
||||
value_type takeFirst() { Q_ASSERT(!isEmpty()); value_type v = std::move(first()); remove(0); return v; }
|
||||
value_type takeLast() { Q_ASSERT(!isEmpty()); value_type v = std::move(last()); remove(size() - 1); return v; }
|
||||
|
||||
QVector<T> &fill(parameter_type t, int size = -1);
|
||||
|
||||
int indexOf(const T &t, int from = 0) const noexcept;
|
||||
int lastIndexOf(const T &t, int from = -1) const noexcept;
|
||||
bool contains(const T &t) const noexcept
|
||||
{
|
||||
return indexOf(t) != -1;
|
||||
}
|
||||
int count(const T &t) const noexcept
|
||||
{
|
||||
return int(std::count(&*cbegin(), &*cend(), t));
|
||||
}
|
||||
|
||||
// QList compatibility
|
||||
void removeAt(int i) { remove(i); }
|
||||
int removeAll(const T &t)
|
||||
{
|
||||
const const_iterator ce = this->cend(), cit = std::find(this->cbegin(), ce, t);
|
||||
if (cit == ce)
|
||||
return 0;
|
||||
int index = cit - this->cbegin();
|
||||
// next operation detaches, so ce, cit, t may become invalidated:
|
||||
const T tCopy = t;
|
||||
const iterator e = end(), it = std::remove(begin() + index, e, tCopy);
|
||||
const int result = std::distance(it, e);
|
||||
erase(it, e);
|
||||
return result;
|
||||
}
|
||||
bool removeOne(const T &t)
|
||||
{
|
||||
const int i = indexOf(t);
|
||||
if (i < 0)
|
||||
return false;
|
||||
remove(i);
|
||||
return true;
|
||||
}
|
||||
T takeAt(int i) { T t = std::move((*this)[i]); remove(i); return t; }
|
||||
void move(int from, int to)
|
||||
{
|
||||
Q_ASSERT_X(from >= 0 && from < size(), "QVector::move(int,int)", "'from' is out-of-range");
|
||||
Q_ASSERT_X(to >= 0 && to < size(), "QVector::move(int,int)", "'to' is out-of-range");
|
||||
if (from == to) // don't detach when no-op
|
||||
return;
|
||||
detach();
|
||||
T * const b = d->begin();
|
||||
if (from < to)
|
||||
std::rotate(b + from, b + from + 1, b + to + 1);
|
||||
else
|
||||
std::rotate(b + to, b + from, b + from + 1);
|
||||
}
|
||||
|
||||
// STL-style
|
||||
iterator begin() { detach(); return d->begin(); }
|
||||
iterator end() { detach(); return d->end(); }
|
||||
|
||||
const_iterator begin() const noexcept { return d->constBegin(); }
|
||||
const_iterator end() const noexcept { return d->constEnd(); }
|
||||
const_iterator cbegin() const noexcept { return d->constBegin(); }
|
||||
const_iterator cend() const noexcept { return d->constEnd(); }
|
||||
const_iterator constBegin() const noexcept { return d->constBegin(); }
|
||||
const_iterator constEnd() const noexcept { return d->constEnd(); }
|
||||
reverse_iterator rbegin() { return reverse_iterator(end()); }
|
||||
reverse_iterator rend() { return reverse_iterator(begin()); }
|
||||
const_reverse_iterator rbegin() const noexcept { return const_reverse_iterator(end()); }
|
||||
const_reverse_iterator rend() const noexcept { return const_reverse_iterator(begin()); }
|
||||
const_reverse_iterator crbegin() const noexcept { return const_reverse_iterator(end()); }
|
||||
const_reverse_iterator crend() const noexcept { return const_reverse_iterator(begin()); }
|
||||
|
||||
iterator erase(const_iterator begin, const_iterator end);
|
||||
inline iterator erase(const_iterator pos) { return erase(pos, pos+1); }
|
||||
|
||||
// more Qt
|
||||
inline T& first() { Q_ASSERT(!isEmpty()); return *begin(); }
|
||||
inline const T &first() const { Q_ASSERT(!isEmpty()); return *begin(); }
|
||||
inline const T &constFirst() const { Q_ASSERT(!isEmpty()); return *begin(); }
|
||||
inline T& last() { Q_ASSERT(!isEmpty()); return *(end()-1); }
|
||||
inline const T &last() const { Q_ASSERT(!isEmpty()); return *(end()-1); }
|
||||
inline const T &constLast() const { Q_ASSERT(!isEmpty()); return *(end()-1); }
|
||||
inline bool startsWith(const T &t) const { return !isEmpty() && first() == t; }
|
||||
inline bool endsWith(const T &t) const { return !isEmpty() && last() == t; }
|
||||
QVector<T> mid(int pos, int len = -1) const;
|
||||
|
||||
T value(int i) const { return value(i, T()); }
|
||||
T value(int i, const T &defaultValue) const;
|
||||
|
||||
void swapItemsAt(int i, int j) {
|
||||
Q_ASSERT_X(i >= 0 && i < size() && j >= 0 && j < size(),
|
||||
"QVector<T>::swap", "index out of range");
|
||||
detach();
|
||||
qSwap(d->begin()[i], d->begin()[j]);
|
||||
}
|
||||
|
||||
// STL compatibility
|
||||
inline void push_back(const T &t) { append(t); }
|
||||
void push_back(rvalue_ref t) { append(std::move(t)); }
|
||||
void push_front(rvalue_ref t) { prepend(std::move(t)); }
|
||||
inline void push_front(const T &t) { prepend(t); }
|
||||
void pop_back() { removeLast(); }
|
||||
void pop_front() { removeFirst(); }
|
||||
|
||||
template <typename ...Args>
|
||||
reference emplace_back(Args&&... args) { return emplaceBack(std::forward<Args>(args)...); }
|
||||
|
||||
inline bool empty() const
|
||||
{ return d->size == 0; }
|
||||
inline reference front() { return first(); }
|
||||
inline const_reference front() const { return first(); }
|
||||
inline reference back() { return last(); }
|
||||
inline const_reference back() const { return last(); }
|
||||
void shrink_to_fit() { squeeze(); }
|
||||
|
||||
// comfort
|
||||
QVector<T> &operator+=(const QVector<T> &l) { append(l.cbegin(), l.cend()); return *this; }
|
||||
inline QVector<T> operator+(const QVector<T> &l) const
|
||||
{ QVector n = *this; n += l; return n; }
|
||||
inline QVector<T> &operator+=(const T &t)
|
||||
{ append(t); return *this; }
|
||||
inline QVector<T> &operator<< (const T &t)
|
||||
{ append(t); return *this; }
|
||||
inline QVector<T> &operator<<(const QVector<T> &l)
|
||||
{ *this += l; return *this; }
|
||||
inline QVector<T> &operator+=(rvalue_ref t)
|
||||
{ append(std::move(t)); return *this; }
|
||||
inline QVector<T> &operator<<(rvalue_ref t)
|
||||
{ append(std::move(t)); return *this; }
|
||||
|
||||
// Consider deprecating in 6.4 or later
|
||||
static QVector<T> fromList(const QVector<T> &list) { return list; }
|
||||
QVector<T> toList() const { return *this; }
|
||||
|
||||
static inline QVector<T> fromVector(const QVector<T> &vector) { return vector; }
|
||||
inline QVector<T> toVector() const { return *this; }
|
||||
};
|
||||
|
||||
#if defined(__cpp_deduction_guides) && __cpp_deduction_guides >= 201606
|
||||
template <typename InputIterator,
|
||||
typename ValueType = typename std::iterator_traits<InputIterator>::value_type,
|
||||
QtPrivate::IfIsInputIterator<InputIterator> = true>
|
||||
QVector(InputIterator, InputIterator) -> QVector<ValueType>;
|
||||
#endif
|
||||
|
||||
template <typename T>
|
||||
inline void QVector<T>::resize_internal(int newSize, Qt::Initialization)
|
||||
{
|
||||
Q_ASSERT(newSize >= 0);
|
||||
|
||||
if (d->needsDetach() || newSize > capacity()) {
|
||||
// must allocate memory
|
||||
DataPointer detached(Data::allocate(d->detachCapacity(newSize),
|
||||
d->detachFlags()));
|
||||
if (size() && newSize) {
|
||||
detached->copyAppend(constBegin(), constBegin() + qMin(newSize, size()));
|
||||
}
|
||||
d.swap(detached);
|
||||
}
|
||||
|
||||
if (newSize < size())
|
||||
d->truncate(newSize);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void QVector<T>::reserve(int asize)
|
||||
{
|
||||
// capacity() == 0 for immutable data, so this will force a detaching below
|
||||
if (asize <= capacity()) {
|
||||
if (d->flags() & Data::CapacityReserved)
|
||||
return; // already reserved, don't shrink
|
||||
if (!d->isShared()) {
|
||||
// accept current allocation, don't shrink
|
||||
d->flags() |= Data::CapacityReserved;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
DataPointer detached(Data::allocate(qMax(asize, size()),
|
||||
d->detachFlags() | Data::CapacityReserved));
|
||||
detached->copyAppend(constBegin(), constEnd());
|
||||
d.swap(detached);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline void QVector<T>::squeeze()
|
||||
{
|
||||
if (d->needsDetach() || size() != capacity()) {
|
||||
// must allocate memory
|
||||
DataPointer detached(Data::allocate(size(), d->detachFlags() & ~Data::CapacityReserved));
|
||||
if (size()) {
|
||||
detached->copyAppend(constBegin(), constEnd());
|
||||
}
|
||||
d.swap(detached);
|
||||
}
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline void QVector<T>::remove(int i, int n)
|
||||
{
|
||||
Q_ASSERT_X(size_t(i) + size_t(n) <= size_t(d->size), "QVector::remove", "index out of range");
|
||||
Q_ASSERT_X(n >= 0, "QVector::remove", "invalid count");
|
||||
|
||||
if (n == 0)
|
||||
return;
|
||||
|
||||
const size_t newSize = size() - n;
|
||||
if (d->needsDetach() ||
|
||||
((d->flags() & Data::CapacityReserved) == 0
|
||||
&& newSize < d->allocatedCapacity()/2)) {
|
||||
// allocate memory
|
||||
DataPointer detached(Data::allocate(d->detachCapacity(newSize),
|
||||
d->detachFlags() & ~(Data::GrowsBackwards | Data::GrowsForward)));
|
||||
const_iterator where = constBegin() + i;
|
||||
if (newSize) {
|
||||
detached->copyAppend(constBegin(), where);
|
||||
detached->copyAppend(where + n, constEnd());
|
||||
}
|
||||
d.swap(detached);
|
||||
} else {
|
||||
// we're detached and we can just move data around
|
||||
d->erase(d->begin() + i, d->begin() + i + n);
|
||||
}
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline void QVector<T>::prepend(const T &t)
|
||||
{ insert(0, 1, t); }
|
||||
template <typename T>
|
||||
void QVector<T>::prepend(rvalue_ref t)
|
||||
{ insert(0, std::move(t)); }
|
||||
|
||||
#if !defined(QT_NO_JAVA_STYLE_ITERATORS)
|
||||
template<typename T>
|
||||
inline T QVector<T>::value(int i, const T &defaultValue) const
|
||||
{
|
||||
return size_t(i) < size_t(d->size) ? at(i) : defaultValue;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline void QVector<T>::append(const_iterator i1, const_iterator i2)
|
||||
{
|
||||
if (i1 == i2)
|
||||
return;
|
||||
const size_t newSize = size() + std::distance(i1, i2);
|
||||
if (d->needsDetach() || newSize > d->allocatedCapacity()) {
|
||||
DataPointer detached(Data::allocate(d->detachCapacity(newSize),
|
||||
d->detachFlags() | Data::GrowsForward));
|
||||
detached->copyAppend(constBegin(), constEnd());
|
||||
detached->copyAppend(i1, i2);
|
||||
d.swap(detached);
|
||||
} else {
|
||||
// we're detached and we can just move data around
|
||||
d->copyAppend(i1, i2);
|
||||
}
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline typename QVector<T>::iterator
|
||||
QVector<T>::insert(int i, int n, parameter_type t)
|
||||
{
|
||||
Q_ASSERT_X(size_t(i) <= size_t(d->size), "QVector<T>::insert", "index out of range");
|
||||
|
||||
// we don't have a quick exit for n == 0
|
||||
// it's not worth wasting CPU cycles for that
|
||||
|
||||
const size_t newSize = size() + n;
|
||||
if (d->needsDetach() || newSize > d->allocatedCapacity()) {
|
||||
typename Data::ArrayOptions flags = d->detachFlags() | Data::GrowsForward;
|
||||
if (size_t(i) <= newSize / 4)
|
||||
flags |= Data::GrowsBackwards;
|
||||
|
||||
DataPointer detached(Data::allocate(d->detachCapacity(newSize), flags));
|
||||
const_iterator where = constBegin() + i;
|
||||
detached->copyAppend(constBegin(), where);
|
||||
detached->copyAppend(n, t);
|
||||
detached->copyAppend(where, constEnd());
|
||||
d.swap(detached);
|
||||
} else {
|
||||
// we're detached and we can just move data around
|
||||
if (i == size()) {
|
||||
d->copyAppend(n, t);
|
||||
} else {
|
||||
T copy(t);
|
||||
d->insert(d.begin() + i, n, copy);
|
||||
}
|
||||
}
|
||||
return d.begin() + i;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
template <typename ...Args>
|
||||
typename QVector<T>::iterator
|
||||
QVector<T>::emplace(int i, Args&&... args)
|
||||
{
|
||||
Q_ASSERT_X(i >= 0 && i <= d->size, "QVector<T>::insert", "index out of range");
|
||||
|
||||
const size_t newSize = size() + 1;
|
||||
if (d->needsDetach() || newSize > d->allocatedCapacity()) {
|
||||
typename Data::ArrayOptions flags = d->detachFlags() | Data::GrowsForward;
|
||||
if (size_t(i) <= newSize / 4)
|
||||
flags |= Data::GrowsBackwards;
|
||||
|
||||
DataPointer detached(Data::allocate(d->detachCapacity(newSize), flags));
|
||||
const_iterator where = constBegin() + i;
|
||||
|
||||
// First, create an element to handle cases, when a user moves
|
||||
// the element from a container to the same container
|
||||
detached->createInPlace(detached.begin() + i, std::forward<Args>(args)...);
|
||||
|
||||
// Then, put the first part of the elements to the new location
|
||||
detached->copyAppend(constBegin(), where);
|
||||
|
||||
// After that, increase the actual size, because we created
|
||||
// one extra element
|
||||
++detached.size;
|
||||
|
||||
// Finally, put the rest of the elements to the new location
|
||||
detached->copyAppend(where, constEnd());
|
||||
|
||||
d.swap(detached);
|
||||
} else {
|
||||
d->emplace(d.begin() + i, std::forward<Args>(args)...);
|
||||
}
|
||||
return d.begin() + i;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
typename QVector<T>::iterator QVector<T>::erase(const_iterator abegin, const_iterator aend)
|
||||
{
|
||||
Q_ASSERT_X(isValidIterator(abegin), "QVector::erase", "The specified iterator argument 'abegin' is invalid");
|
||||
Q_ASSERT_X(isValidIterator(aend), "QVector::erase", "The specified iterator argument 'aend' is invalid");
|
||||
Q_ASSERT(aend >= abegin);
|
||||
|
||||
int i = std::distance(d.constBegin(), abegin);
|
||||
int n = std::distance(abegin, aend);
|
||||
remove(i, n);
|
||||
|
||||
return d.begin() + i;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline QVector<T> &QVector<T>::fill(parameter_type t, int newSize)
|
||||
{
|
||||
if (newSize == -1)
|
||||
newSize = size();
|
||||
if (d->needsDetach() || newSize > capacity()) {
|
||||
// must allocate memory
|
||||
DataPointer detached(Data::allocate(d->detachCapacity(newSize),
|
||||
d->detachFlags()));
|
||||
detached->copyAppend(newSize, t);
|
||||
d.swap(detached);
|
||||
} else {
|
||||
// we're detached
|
||||
const T copy(t);
|
||||
d->assign(d.begin(), d.begin() + qMin(size(), newSize), t);
|
||||
if (newSize > size())
|
||||
d->copyAppend(newSize - size(), copy);
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
namespace QtPrivate {
|
||||
template <typename T, typename U>
|
||||
int indexOf(const QVector<T> &vector, const U &u, int from)
|
||||
{
|
||||
if (from < 0)
|
||||
from = qMax(from + vector.size(), 0);
|
||||
if (from < vector.size()) {
|
||||
auto n = vector.begin() + from - 1;
|
||||
auto e = vector.end();
|
||||
while (++n != e)
|
||||
if (*n == u)
|
||||
return int(n - vector.begin());
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
template <typename T, typename U>
|
||||
int lastIndexOf(const QVector<T> &vector, const U &u, int from)
|
||||
{
|
||||
if (from < 0)
|
||||
from += vector.d->size;
|
||||
else if (from >= vector.size())
|
||||
from = vector.size() - 1;
|
||||
if (from >= 0) {
|
||||
auto b = vector.begin();
|
||||
auto n = vector.begin() + from + 1;
|
||||
while (n != b) {
|
||||
if (*--n == u)
|
||||
return int(n - b);
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
int QVector<T>::indexOf(const T &t, int from) const noexcept
|
||||
{
|
||||
return QtPrivate::indexOf<T, T>(*this, t, from);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
int QVector<T>::lastIndexOf(const T &t, int from) const noexcept
|
||||
{
|
||||
return QtPrivate::lastIndexOf(*this, t, from);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline QVector<T> QVector<T>::mid(int pos, int len) const
|
||||
{
|
||||
qsizetype p = pos;
|
||||
qsizetype l = len;
|
||||
using namespace QtPrivate;
|
||||
switch (QContainerImplHelper::mid(d.size, &p, &l)) {
|
||||
case QContainerImplHelper::Null:
|
||||
case QContainerImplHelper::Empty:
|
||||
return QVector();
|
||||
case QContainerImplHelper::Full:
|
||||
return *this;
|
||||
case QContainerImplHelper::Subset:
|
||||
break;
|
||||
}
|
||||
|
||||
// Allocate memory
|
||||
DataPointer copied(Data::allocate(l));
|
||||
copied->copyAppend(constBegin() + p, constBegin() + p + l);
|
||||
return copied;
|
||||
}
|
||||
|
||||
Q_DECLARE_SEQUENTIAL_ITERATOR(Vector)
|
||||
Q_DECLARE_MUTABLE_SEQUENTIAL_ITERATOR(Vector)
|
||||
|
||||
template <typename T>
|
||||
size_t qHash(const QVector<T> &key, size_t seed = 0)
|
||||
noexcept(noexcept(qHashRange(key.cbegin(), key.cend(), seed)))
|
||||
{
|
||||
return qHashRange(key.cbegin(), key.cend(), seed);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
auto operator<(const QVector<T> &lhs, const QVector<T> &rhs)
|
||||
noexcept(noexcept(std::lexicographical_compare(lhs.begin(), lhs.end(),
|
||||
rhs.begin(), rhs.end())))
|
||||
-> decltype(std::declval<T>() < std::declval<T>())
|
||||
{
|
||||
return std::lexicographical_compare(lhs.begin(), lhs.end(),
|
||||
rhs.begin(), rhs.end());
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
auto operator>(const QVector<T> &lhs, const QVector<T> &rhs)
|
||||
noexcept(noexcept(lhs < rhs))
|
||||
-> decltype(lhs < rhs)
|
||||
{
|
||||
return rhs < lhs;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
auto operator<=(const QVector<T> &lhs, const QVector<T> &rhs)
|
||||
noexcept(noexcept(lhs < rhs))
|
||||
-> decltype(lhs < rhs)
|
||||
{
|
||||
return !(lhs > rhs);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
auto operator>=(const QVector<T> &lhs, const QVector<T> &rhs)
|
||||
noexcept(noexcept(lhs < rhs))
|
||||
-> decltype(lhs < rhs)
|
||||
{
|
||||
return !(lhs < rhs);
|
||||
}
|
||||
|
||||
/*
|
||||
### Qt 5:
|
||||
### This needs to be removed for next releases of Qt. It is a workaround for vc++ because
|
||||
### Qt exports QPolygon and QPolygonF that inherit QVector<QPoint> and
|
||||
### QVector<QPointF> respectively.
|
||||
*/
|
||||
|
||||
#if defined(Q_CC_MSVC) && !defined(QT_BUILD_CORE_LIB)
|
||||
QT_BEGIN_INCLUDE_NAMESPACE
|
||||
#include <QtCore/qpoint.h>
|
||||
QT_END_INCLUDE_NAMESPACE
|
||||
extern template class Q_CORE_EXPORT QVector<QPointF>;
|
||||
extern template class Q_CORE_EXPORT QVector<QPoint>;
|
||||
using QMutableVectorIterator = QMutableListIterator<T>;
|
||||
template<typename T>
|
||||
using QVectorIterator = QListIterator<T>;
|
||||
#endif
|
||||
|
||||
QVector<uint> QStringView::toUcs4() const { return QtPrivate::convertToUcs4(*this); }
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#include <QtCore/qbytearraylist.h>
|
||||
#include <QtCore/qstringlist.h>
|
||||
|
||||
#endif // QVECTOR_H
|
||||
|
|
|
|||
|
|
@ -49,6 +49,7 @@
|
|||
#include <QtCore/qbytearray.h>
|
||||
#include <QtCore/qrect.h>
|
||||
#include <QtCore/qstring.h>
|
||||
#include <QtCore/qcontainerfwd.h>
|
||||
|
||||
#if defined(Q_OS_DARWIN) || defined(Q_QDOC)
|
||||
Q_FORWARD_DECLARE_MUTABLE_CG_TYPE(CGImage);
|
||||
|
|
@ -63,7 +64,6 @@ class QIODevice;
|
|||
class QStringList;
|
||||
class QTransform;
|
||||
class QVariant;
|
||||
template <class T> class QVector;
|
||||
|
||||
struct QImageData;
|
||||
|
||||
|
|
|
|||
|
|
@ -44,6 +44,7 @@
|
|||
#include <QtCore/qatomic.h>
|
||||
#include <QtCore/qrect.h>
|
||||
#include <QtGui/qwindowdefs.h>
|
||||
#include <QtCore/qcontainerfwd.h>
|
||||
|
||||
#ifndef QT_NO_DATASTREAM
|
||||
#include <QtCore/qdatastream.h>
|
||||
|
|
@ -52,7 +53,6 @@
|
|||
QT_BEGIN_NAMESPACE
|
||||
|
||||
|
||||
template <class T> class QVector;
|
||||
class QVariant;
|
||||
|
||||
struct QRegionPrivate;
|
||||
|
|
|
|||
|
|
@ -47,6 +47,7 @@
|
|||
#include <QtCore/qvariant.h>
|
||||
#include <QtGui/qfont.h>
|
||||
#include <QtCore/qurl.h>
|
||||
#include <QtCore/qcontainerfwd.h>
|
||||
Q_MOC_INCLUDE(<QtGui/qtextcursor.h>)
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
|
@ -68,7 +69,6 @@ class QRectF;
|
|||
class QTextOption;
|
||||
class QTextCursor;
|
||||
|
||||
template<typename T> class QVector;
|
||||
|
||||
namespace Qt
|
||||
{
|
||||
|
|
|
|||
|
|
@ -347,12 +347,12 @@ struct QScriptItem
|
|||
int glyph_data_offset;
|
||||
Q_DECL_CONSTEXPR QFixed height() const noexcept { return ascent + descent; }
|
||||
private:
|
||||
friend class QVector<QScriptItem>;
|
||||
QScriptItem() {} // for QVector, don't use
|
||||
friend class QList<QScriptItem>;
|
||||
QScriptItem() {} // for QList, don't use
|
||||
};
|
||||
Q_DECLARE_TYPEINFO(QScriptItem, Q_PRIMITIVE_TYPE);
|
||||
|
||||
typedef QVector<QScriptItem> QScriptItemArray;
|
||||
typedef QList<QScriptItem> QScriptItemArray;
|
||||
|
||||
struct Q_AUTOTEST_EXPORT QScriptLine
|
||||
{
|
||||
|
|
|
|||
|
|
@ -61,13 +61,12 @@
|
|||
#include <QtCore/qglobal.h>
|
||||
#include <QtCore/qpair.h>
|
||||
#include <QtCore/qurl.h>
|
||||
#include <QtCore/qcontainerfwd.h>
|
||||
|
||||
#include <map>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
template <typename T> class QVector;
|
||||
|
||||
class Q_AUTOTEST_EXPORT QHstsCache
|
||||
{
|
||||
public:
|
||||
|
|
|
|||
|
|
@ -47,6 +47,7 @@
|
|||
|
||||
#include <QtCore/qcryptographichash.h>
|
||||
#include <QtCore/qobject.h>
|
||||
#include <QtCore/qcontainerfwd.h>
|
||||
|
||||
Q_MOC_INCLUDE(<QtNetwork/QSslPreSharedKeyAuthenticator>)
|
||||
|
||||
|
|
@ -109,7 +110,6 @@ private:
|
|||
};
|
||||
|
||||
class QSslPreSharedKeyAuthenticator;
|
||||
template<class> class QVector;
|
||||
class QSslConfiguration;
|
||||
class QSslCipher;
|
||||
class QSslError;
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@
|
|||
|
||||
#include "qoscmessage_p.h"
|
||||
|
||||
#include <QtCore/QVector>
|
||||
#include <QtCore/QList>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
|
|
@ -51,22 +51,22 @@ class QByteArray;
|
|||
|
||||
class QOscBundle
|
||||
{
|
||||
QOscBundle(); // for QVector, don't use
|
||||
friend class QVector<QOscBundle>;
|
||||
QOscBundle(); // for QList, don't use
|
||||
friend class QList<QOscBundle>;
|
||||
public:
|
||||
explicit QOscBundle(const QByteArray &data);
|
||||
|
||||
bool isValid() const { return m_isValid; }
|
||||
QVector<QOscBundle> bundles() const { return m_bundles; }
|
||||
QVector<QOscMessage> messages() const { return m_messages; }
|
||||
QList<QOscBundle> bundles() const { return m_bundles; }
|
||||
QList<QOscMessage> messages() const { return m_messages; }
|
||||
|
||||
private:
|
||||
bool m_isValid;
|
||||
bool m_immediate;
|
||||
quint32 m_timeEpoch;
|
||||
quint32 m_timePico;
|
||||
QVector<QOscBundle> m_bundles;
|
||||
QVector<QOscMessage> m_messages;
|
||||
QList<QOscBundle> m_bundles;
|
||||
QList<QOscMessage> m_messages;
|
||||
};
|
||||
Q_DECLARE_TYPEINFO(QOscBundle, Q_MOVABLE_TYPE);
|
||||
|
||||
|
|
|
|||
|
|
@ -43,7 +43,6 @@
|
|||
|
||||
#include <QtCore/QByteArray>
|
||||
#include <QtCore/QVariant>
|
||||
#include <QtCore/QVector>
|
||||
#include <QtCore/QList>
|
||||
|
||||
|
||||
|
|
@ -51,8 +50,8 @@ QT_BEGIN_NAMESPACE
|
|||
|
||||
class QOscMessage
|
||||
{
|
||||
QOscMessage(); // for QVector, don't use
|
||||
friend class QVector<QOscMessage>;
|
||||
QOscMessage(); // for QList, don't use
|
||||
friend class QList<QOscMessage>;
|
||||
public:
|
||||
explicit QOscMessage(const QByteArray &data);
|
||||
|
||||
|
|
|
|||
|
|
@ -54,11 +54,11 @@
|
|||
#include <QtSql/private/qtsqlglobal_p.h>
|
||||
#include "QtSql/qsqlresult.h"
|
||||
#include "QtSql/private/qsqlresult_p.h"
|
||||
#include <QtCore/qcontainerfwd.h>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class QVariant;
|
||||
template <typename T> class QVector;
|
||||
|
||||
class QSqlCachedResultPrivate;
|
||||
|
||||
|
|
|
|||
|
|
@ -42,6 +42,7 @@
|
|||
|
||||
#include <QtSql/qtsqlglobal.h>
|
||||
#include <QtCore/qvariant.h>
|
||||
#include <QtCore/qcontainerfwd.h>
|
||||
|
||||
// for testing:
|
||||
class tst_QSqlQuery;
|
||||
|
|
@ -51,7 +52,7 @@ QT_BEGIN_NAMESPACE
|
|||
|
||||
class QString;
|
||||
class QSqlRecord;
|
||||
template <typename T> class QVector;
|
||||
class QVariant;
|
||||
class QSqlDriver;
|
||||
class QSqlError;
|
||||
class QSqlResultPrivate;
|
||||
|
|
|
|||
|
|
@ -54,11 +54,10 @@
|
|||
#include <QtWidgets/private/qtwidgetsglobal_p.h>
|
||||
#include "QtWidgets/qlayoutitem.h"
|
||||
#include "QtWidgets/qstyle.h"
|
||||
#include <QtCore/qcontainerfwd.h>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
template <typename T> class QVector;
|
||||
|
||||
struct QLayoutStruct
|
||||
{
|
||||
inline void init(int stretchFactor = 0, int minSize = 0) {
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@
|
|||
"qconfig.h" => "QtConfig",
|
||||
"qplugin.h" => "QtPlugin",
|
||||
"qalgorithms.h" => "QtAlgorithms",
|
||||
"qlist.h" => "QList",
|
||||
"qvector.h" => "QVector",
|
||||
"qcontainerfwd.h" => "QtContainerFwd",
|
||||
"qdebug.h" => "QtDebug",
|
||||
"qevent.h" => "QtEvents",
|
||||
|
|
|
|||
|
|
@ -1320,13 +1320,13 @@ void tst_QMetaObject::normalizedSignature_data()
|
|||
QTest::newRow("function ptr spaces") << "void foo( void ( * ) ( void ))" << "void foo(void(*)())";
|
||||
QTest::newRow("function ptr void*") << "void foo(void(*)(void*))" << "void foo(void(*)(void*))";
|
||||
QTest::newRow("function ptr void* spaces") << "void foo( void ( * ) ( void * ))" << "void foo(void(*)(void*))";
|
||||
QTest::newRow("template args") << " void foo( QMap<a, a>, QVector<b>) "
|
||||
<< "void foo(QMap<a,a>,QVector<b>)";
|
||||
QTest::newRow("template args") << " void foo( QMap<a, a>, QList<b>) "
|
||||
<< "void foo(QMap<a,a>,QList<b>)";
|
||||
QTest::newRow("void template args") << " void foo( Foo<void>, Bar<void> ) "
|
||||
<< "void foo(Foo<void>,Bar<void>)";
|
||||
QTest::newRow("void* template args") << " void foo( Foo<void*>, Bar<void *> ) "
|
||||
<< "void foo(Foo<void*>,Bar<void*>)";
|
||||
QTest::newRow("rettype") << "QVector<int, int> foo()" << "QVector<int,int>foo()";
|
||||
QTest::newRow("rettype") << "QList<int, int> foo()" << "QList<int,int>foo()";
|
||||
QTest::newRow("rettype void template") << "Foo<void> foo()" << "Foo<void>foo()";
|
||||
QTest::newRow("const rettype") << "const QString *foo()" << "const QString*foo()";
|
||||
QTest::newRow("const ref") << "const QString &foo()" << "const QString&foo()";
|
||||
|
|
@ -1337,18 +1337,18 @@ void tst_QMetaObject::normalizedSignature_data()
|
|||
QTest::newRow("const4") << "void foo(const int)" << "void foo(int)";
|
||||
QTest::newRow("const5") << "void foo(const int, int const, const int &, int const &)"
|
||||
<< "void foo(int,int,int,int)";
|
||||
QTest::newRow("const6") << "void foo(QVector<const int>)" << "void foo(QVector<const int>)";
|
||||
QTest::newRow("const7") << "void foo(QVector<const int*>)" << "void foo(QVector<const int*>)";
|
||||
QTest::newRow("const8") << "void foo(QVector<int const*>)" << "void foo(QVector<const int*>)";
|
||||
QTest::newRow("const6") << "void foo(QList<const int>)" << "void foo(QList<const int>)";
|
||||
QTest::newRow("const7") << "void foo(QList<const int*>)" << "void foo(QList<const int*>)";
|
||||
QTest::newRow("const8") << "void foo(QList<int const*>)" << "void foo(QList<const int*>)";
|
||||
QTest::newRow("const9") << "void foo(const Foo<Bar>)" << "void foo(Foo<Bar>)";
|
||||
QTest::newRow("const10") << "void foo(Foo<Bar>const)" << "void foo(Foo<Bar>)";
|
||||
QTest::newRow("const11") << "void foo(Foo<Bar> *const)" << "void foo(Foo<Bar>*)";
|
||||
QTest::newRow("const12") << "void foo(Foo<Bar>const*const *const)" << "void foo(const Foo<Bar>*const*)";
|
||||
QTest::newRow("const13") << "void foo(const Foo<Bar>&)" << "void foo(Foo<Bar>)";
|
||||
QTest::newRow("const14") << "void foo(Foo<Bar>const&)" << "void foo(Foo<Bar>)";
|
||||
QTest::newRow("QList") << "void foo(QList<int>)" << "void foo(QVector<int>)";
|
||||
QTest::newRow("QList1") << "void foo(const Template<QList, MyQList const>)"
|
||||
<< "void foo(Template<QVector,const MyQList>)";
|
||||
QTest::newRow("QVector") << "void foo(QVector<int>)" << "void foo(QList<int>)";
|
||||
QTest::newRow("QVector1") << "void foo(const Template<QVector, MyQList const>)"
|
||||
<< "void foo(Template<QList,const MyQList>)";
|
||||
|
||||
QTest::newRow("refref") << "const char* foo(const X &&,X const &&, const X* &&) && "
|
||||
<< "const char*foo(const X&&,const X&&,const X*&&)&&";
|
||||
|
|
@ -1373,13 +1373,13 @@ void tst_QMetaObject::normalizedType_data()
|
|||
QTest::newRow("white") << " int " << "int";
|
||||
QTest::newRow("const1") << "int const *" << "const int*";
|
||||
QTest::newRow("const2") << "const int *" << "const int*";
|
||||
QTest::newRow("template1") << "QVector<int const *>" << "QVector<const int*>";
|
||||
QTest::newRow("template2") << "QVector<const int *>" << "QVector<const int*>";
|
||||
QTest::newRow("template1") << "QList<int const *>" << "QList<const int*>";
|
||||
QTest::newRow("template2") << "QList<const int *>" << "QList<const int*>";
|
||||
QTest::newRow("template3") << "QMap<QString, int>" << "QMap<QString,int>";
|
||||
QTest::newRow("template4") << "const QMap<QString, int> &" << "QMap<QString,int>";
|
||||
QTest::newRow("template5") << "QVector< ::Foo::Bar>" << "QVector<::Foo::Bar>";
|
||||
QTest::newRow("template6") << "QVector<::Foo::Bar>" << "QVector<::Foo::Bar>";
|
||||
QTest::newRow("template7") << "QVector<QVector<int> >" << "QVector<QVector<int>>";
|
||||
QTest::newRow("template5") << "QList< ::Foo::Bar>" << "QList<::Foo::Bar>";
|
||||
QTest::newRow("template6") << "QList<::Foo::Bar>" << "QList<::Foo::Bar>";
|
||||
QTest::newRow("template7") << "QList<QList<int> >" << "QList<QList<int>>";
|
||||
QTest::newRow("template8") << "QMap<const int, const short*>" << "QMap<const int,const short*>";
|
||||
QTest::newRow("template9") << "QPair<const QPair<int, int const *> , QPair<QHash<int, const char*> > >"
|
||||
#ifdef _LIBCPP_VERSION
|
||||
|
|
@ -1387,7 +1387,7 @@ void tst_QMetaObject::normalizedType_data()
|
|||
#else
|
||||
<< "std::pair<const std::pair<int,const int*>,std::pair<QHash<int,const char*>>>";
|
||||
#endif
|
||||
QTest::newRow("template10") << "QList<int const * const> const" << "QVector<const int*const>";
|
||||
QTest::newRow("template10") << "QVector<int const * const> const" << "QList<const int*const>";
|
||||
QTest::newRow("template11") << " QSharedPointer<QVarLengthArray< QString const, ( 16>> 2 )> > const & "
|
||||
<< "QSharedPointer<QVarLengthArray<const QString,(16>>2)>>";
|
||||
QTest::newRow("template_sub") << "X<( Y < 8), (Y >6)> const & " << "X<(Y<8),(Y>6)>";
|
||||
|
|
@ -1402,7 +1402,8 @@ void tst_QMetaObject::normalizedType_data()
|
|||
QTest::newRow("struct2") << "struct foo const*" << "const foo*";
|
||||
QTest::newRow("enum") << "enum foo" << "foo";
|
||||
QTest::newRow("void") << "void" << "void";
|
||||
QTest::newRow("QList") << "QList<int>" << "QVector<int>";
|
||||
QTest::newRow("QList") << "QList<int>" << "QList<int>";
|
||||
QTest::newRow("QVector") << "QVector<int>" << "QList<int>";
|
||||
QTest::newRow("refref") << "X const*const&&" << "const X*const&&";
|
||||
QTest::newRow("refref2") << "const X<T const&&>&&" << "const X<const T&&>&&";
|
||||
QTest::newRow("long1") << "long unsigned int long" << "unsigned long long";
|
||||
|
|
|
|||
|
|
@ -583,11 +583,11 @@ void tst_QMetaType::typeName_data()
|
|||
// automatic registration
|
||||
QTest::newRow("QHash<int,int>") << ::qMetaTypeId<QHash<int, int> >() << QString::fromLatin1("QHash<int,int>");
|
||||
QTest::newRow("QMap<int,int>") << ::qMetaTypeId<QMap<int, int> >() << QString::fromLatin1("QMap<int,int>");
|
||||
QTest::newRow("QVector<QMap<int,int>>") << ::qMetaTypeId<QVector<QMap<int, int> > >() << QString::fromLatin1("QVector<QMap<int,int>>");
|
||||
QTest::newRow("QVector<QMap<int,int>>") << ::qMetaTypeId<QVector<QMap<int, int> > >() << QString::fromLatin1("QList<QMap<int,int>>");
|
||||
|
||||
// automatic registration with automatic QList to QVector aliasing
|
||||
QTest::newRow("QList<int>") << ::qMetaTypeId<QList<int> >() << QString::fromLatin1("QVector<int>");
|
||||
QTest::newRow("QVector<QList<int>>") << ::qMetaTypeId<QVector<QList<int> > >() << QString::fromLatin1("QVector<QVector<int>>");
|
||||
QTest::newRow("QList<int>") << ::qMetaTypeId<QList<int> >() << QString::fromLatin1("QList<int>");
|
||||
QTest::newRow("QVector<QList<int>>") << ::qMetaTypeId<QVector<QList<int> > >() << QString::fromLatin1("QList<QList<int>>");
|
||||
|
||||
QTest::newRow("CustomQObject*") << ::qMetaTypeId<CustomQObject*>() << QString::fromLatin1("CustomQObject*");
|
||||
QTest::newRow("CustomGadget") << ::qMetaTypeId<CustomGadget>() << QString::fromLatin1("CustomGadget");
|
||||
|
|
|
|||
|
|
@ -240,7 +240,7 @@ public:
|
|||
*/
|
||||
class MissedBaseline
|
||||
{
|
||||
friend class QVector<MissedBaseline>;
|
||||
friend class QList<MissedBaseline>;
|
||||
MissedBaseline() {} // for QVector, don't use
|
||||
public:
|
||||
MissedBaseline(const QString &aId,
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ add_subdirectory(qfreelist)
|
|||
add_subdirectory(qhash)
|
||||
add_subdirectory(qhashfunctions)
|
||||
add_subdirectory(qline)
|
||||
add_subdirectory(qlist)
|
||||
add_subdirectory(qmakearray)
|
||||
add_subdirectory(qmap)
|
||||
add_subdirectory(qmargins)
|
||||
|
|
@ -38,7 +39,6 @@ add_subdirectory(qsizef)
|
|||
add_subdirectory(qstl)
|
||||
add_subdirectory(qtimeline)
|
||||
add_subdirectory(qvarlengtharray)
|
||||
add_subdirectory(qvector)
|
||||
add_subdirectory(qversionnumber)
|
||||
if(APPLE)
|
||||
add_subdirectory(qmacautoreleasepool)
|
||||
|
|
|
|||
|
|
@ -564,7 +564,7 @@ template<typename ... T>
|
|||
struct ContainerDuplicatedValuesStrategy<std::vector<T...>> : ContainerAcceptsDuplicateValues {};
|
||||
|
||||
template<typename ... T>
|
||||
struct ContainerDuplicatedValuesStrategy<QVector<T...>> : ContainerAcceptsDuplicateValues {};
|
||||
struct ContainerDuplicatedValuesStrategy<QList<T...>> : ContainerAcceptsDuplicateValues {};
|
||||
|
||||
template<typename ... T>
|
||||
struct ContainerDuplicatedValuesStrategy<QVarLengthArray<T...>> : ContainerAcceptsDuplicateValues {};
|
||||
|
|
|
|||
|
|
@ -4,9 +4,9 @@
|
|||
## tst_qvector Test:
|
||||
#####################################################################
|
||||
|
||||
qt_add_test(tst_qvector
|
||||
qt_add_test(tst_qlist
|
||||
SOURCES
|
||||
tst_qvector.cpp
|
||||
tst_qlist.cpp
|
||||
)
|
||||
|
||||
## Scopes:
|
||||
|
|
@ -2,6 +2,6 @@ CONFIG += testcase
|
|||
qtConfig(c++11): CONFIG += c++11
|
||||
qtConfig(c++14): CONFIG += c++14
|
||||
qtConfig(c++1z): CONFIG += c++1z
|
||||
TARGET = tst_qvector
|
||||
TARGET = tst_qlist
|
||||
QT = core testlib
|
||||
SOURCES = $$PWD/tst_qvector.cpp
|
||||
SOURCES = $$PWD/tst_qlist.cpp
|
||||
File diff suppressed because it is too large
Load Diff
|
|
@ -16,6 +16,7 @@ SUBDIRS=\
|
|||
qhash \
|
||||
qhashfunctions \
|
||||
qline \
|
||||
qlist \
|
||||
qmakearray \
|
||||
qmap \
|
||||
qmargins \
|
||||
|
|
@ -38,7 +39,6 @@ SUBDIRS=\
|
|||
qstl \
|
||||
qtimeline \
|
||||
qvarlengtharray \
|
||||
qvector \
|
||||
qversionnumber
|
||||
|
||||
darwin: SUBDIRS += qmacautoreleasepool
|
||||
|
|
|
|||
|
|
@ -402,7 +402,7 @@ void tst_QDBusMetaType::invalidTypes()
|
|||
else if (qstrcmp(QTest::currentDataTag(), "Invalid7") == 0)
|
||||
QTest::ignoreMessage(QtWarningMsg, "QDBusMarshaller: type `Invalid7' produces invalid D-BUS signature `()' (Did you forget to call beginStructure() ?)");
|
||||
else if (qstrcmp(QTest::currentDataTag(), "QList<Invalid0>") == 0)
|
||||
QTest::ignoreMessage(QtWarningMsg, "QDBusMarshaller: type `QVector<Invalid0>' produces invalid D-BUS signature `a' (Did you forget to call beginStructure() ?)");
|
||||
QTest::ignoreMessage(QtWarningMsg, "QDBusMarshaller: type `QList<Invalid0>' produces invalid D-BUS signature `a' (Did you forget to call beginStructure() ?)");
|
||||
|
||||
staticTypes();
|
||||
staticTypes(); // run twice: the error messages should be printed once only
|
||||
|
|
|
|||
|
|
@ -1251,7 +1251,7 @@
|
|||
"required": false,
|
||||
"scriptable": true,
|
||||
"stored": true,
|
||||
"type": "QVector<Foo::Bar::Flags>",
|
||||
"type": "QList<Foo::Bar::Flags>",
|
||||
"user": false,
|
||||
"write": "setFlagsList"
|
||||
}
|
||||
|
|
@ -2699,7 +2699,7 @@
|
|||
"access": "public",
|
||||
"arguments": [
|
||||
{
|
||||
"type": "QVector<QVector<int>>"
|
||||
"type": "QList<QList<int>>"
|
||||
}
|
||||
],
|
||||
"name": "foo",
|
||||
|
|
@ -2709,7 +2709,7 @@
|
|||
"access": "public",
|
||||
"arguments": [
|
||||
{
|
||||
"type": "QVector<QVector<int>>"
|
||||
"type": "QList<QList<int>>"
|
||||
}
|
||||
],
|
||||
"name": "foo2",
|
||||
|
|
@ -2719,7 +2719,7 @@
|
|||
"access": "public",
|
||||
"arguments": [
|
||||
{
|
||||
"type": "QVector<::AAA::BaseA*>"
|
||||
"type": "QList<::AAA::BaseA*>"
|
||||
}
|
||||
],
|
||||
"name": "bar",
|
||||
|
|
@ -2729,7 +2729,7 @@
|
|||
"access": "public",
|
||||
"arguments": [
|
||||
{
|
||||
"type": "QVector<::AAA::BaseA*>"
|
||||
"type": "QList<::AAA::BaseA*>"
|
||||
}
|
||||
],
|
||||
"name": "bar2",
|
||||
|
|
@ -2739,7 +2739,7 @@
|
|||
"access": "public",
|
||||
"arguments": [
|
||||
{
|
||||
"type": "QVector<const ::AAA::BaseA*>"
|
||||
"type": "QList<const ::AAA::BaseA*>"
|
||||
}
|
||||
],
|
||||
"name": "bar3",
|
||||
|
|
|
|||
|
|
@ -1804,32 +1804,16 @@ signals:
|
|||
class QTBUG12260_defaultTemplate_Object : public QObject
|
||||
{ Q_OBJECT
|
||||
public slots:
|
||||
#if !(defined(Q_CC_GNU) && __GNUC__ == 4 && __GNUC_MINOR__ <= 3) || defined(Q_MOC_RUN)
|
||||
void doSomething(QHash<QString, QVariant> values = QHash<QString, QVariant>() ) { Q_UNUSED(values); }
|
||||
void doSomethingElse(QSharedPointer<QVarLengthArray<QString, (16 >> 2)> > val
|
||||
= QSharedPointer<QVarLengthArray<QString, (16 >> 2)> >() )
|
||||
{ Q_UNUSED(val); }
|
||||
#else
|
||||
// we want to test the previous function, but gcc < 4.4 seemed to have a bug similar to the one moc has.
|
||||
typedef QHash<QString, QVariant> WorkaroundGCCBug;
|
||||
void doSomething(QHash<QString, QVariant> values = WorkaroundGCCBug() ) { Q_UNUSED(values); }
|
||||
void doSomethingElse(QSharedPointer<QVarLengthArray<QString, (16 >> 2)> > val
|
||||
= (QSharedPointer<QVarLengthArray<QString, (16 >> 2)> >()) )
|
||||
{ Q_UNUSED(val); }
|
||||
#endif
|
||||
|
||||
void doAnotherThing(bool a = (1 < 3), bool b = (1 > 4)) { Q_UNUSED(a); Q_UNUSED(b); }
|
||||
|
||||
#if defined(Q_MOC_RUN) || (defined(Q_COMPILER_AUTO_TYPE) && !(defined(Q_CC_CLANG) && Q_CC_CLANG < 304))
|
||||
// There is no Q_COMPILER_>> but if compiler support auto, it should also support >>
|
||||
void performSomething(QVector<QList<QString>> e = QVector<QList<QString>>(8 < 1),
|
||||
QHash<int, QVector<QString>> h = QHash<int, QVector<QString>>())
|
||||
void performSomething(QList<QList<QString>> e = QList<QList<QString>>(8 < 1),
|
||||
QHash<int, QList<QString>> h = QHash<int, QList<QString>>())
|
||||
{ Q_UNUSED(e); Q_UNUSED(h); }
|
||||
#else
|
||||
void performSomething(QVector<QList<QString> > e = QVector<QList<QString> >(),
|
||||
QHash<int, QVector<QString> > h = (QHash<int, QVector<QString> >()))
|
||||
{ Q_UNUSED(e); Q_UNUSED(h); }
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
|
|
@ -1838,7 +1822,7 @@ void tst_Moc::QTBUG12260_defaultTemplate()
|
|||
QVERIFY(QTBUG12260_defaultTemplate_Object::staticMetaObject.indexOfSlot("doSomething(QHash<QString,QVariant>)") != -1);
|
||||
QVERIFY(QTBUG12260_defaultTemplate_Object::staticMetaObject.indexOfSlot("doAnotherThing(bool,bool)") != -1);
|
||||
QVERIFY(QTBUG12260_defaultTemplate_Object::staticMetaObject.indexOfSlot("doSomethingElse(QSharedPointer<QVarLengthArray<QString,(16>>2)>>)") != -1);
|
||||
QVERIFY(QTBUG12260_defaultTemplate_Object::staticMetaObject.indexOfSlot("performSomething(QVector<QList<QString>>,QHash<int,QVector<QString>>)") != -1);
|
||||
QVERIFY(QTBUG12260_defaultTemplate_Object::staticMetaObject.indexOfSlot("performSomething(QList<QList<QString>>,QHash<int,QList<QString>>)") != -1);
|
||||
}
|
||||
|
||||
void tst_Moc::notifyError()
|
||||
|
|
|
|||
Loading…
Reference in New Issue