diff --git a/src/corelib/tools/qlist.h b/src/corelib/tools/qlist.h index 27868f7313..513d7eafe1 100644 --- a/src/corelib/tools/qlist.h +++ b/src/corelib/tools/qlist.h @@ -51,7 +51,9 @@ #include #include #include +#if QT_VERSION < QT_VERSION_CHECK(6,0,0) #include +#endif #include #include @@ -403,10 +405,14 @@ public: static QList fromVector(const QVector &vector); static QList fromSet(const QSet &set); +#if QT_VERSION < QT_VERSION_CHECK(6,0,0) + Q_DECL_DEPRECATED_X("Use QList(list.begin(), list.end()) instead.") static inline QList fromStdList(const std::list &list) { QList tmp; std::copy(list.begin(), list.end(), std::back_inserter(tmp)); return tmp; } + Q_DECL_DEPRECATED_X("Use std::list(list.begin(), list.end()) instead.") inline std::list toStdList() const { std::list tmp; std::copy(constBegin(), constEnd(), std::back_inserter(tmp)); return tmp; } +#endif private: Node *detach_helper_grow(int i, int n); diff --git a/src/corelib/tools/qvector.h b/src/corelib/tools/qvector.h index d6baa76a30..4e148c9c55 100644 --- a/src/corelib/tools/qvector.h +++ b/src/corelib/tools/qvector.h @@ -49,7 +49,9 @@ #include #include +#if QT_VERSION < QT_VERSION_CHECK(6,0,0) #include +#endif #include #include @@ -292,10 +294,14 @@ public: static QVector fromList(const QList &list); +#if QT_VERSION < QT_VERSION_CHECK(6,0,0) + Q_DECL_DEPRECATED_X("Use QVector(vector.begin(), vector.end()) instead.") static inline QVector fromStdVector(const std::vector &vector) { QVector tmp; tmp.reserve(int(vector.size())); std::copy(vector.begin(), vector.end(), std::back_inserter(tmp)); return tmp; } + Q_DECL_DEPRECATED_X("Use std::vector(vector.begin(), vector.end()) instead.") inline std::vector toStdVector() const { return std::vector(d->begin(), d->end()); } +#endif private: // ### Qt6: remove methods, they are unused void reallocData(const int size, const int alloc, QArrayData::AllocationOptions options = QArrayData::Default); diff --git a/tests/auto/corelib/tools/qlist/tst_qlist.cpp b/tests/auto/corelib/tools/qlist/tst_qlist.cpp index 995aa245d1..7fb3e67462 100644 --- a/tests/auto/corelib/tools/qlist/tst_qlist.cpp +++ b/tests/auto/corelib/tools/qlist/tst_qlist.cpp @@ -367,9 +367,11 @@ private slots: void toSetOptimal() const; void toSetMovable() const; void toSetComplex() const; +#if QT_VERSION < QT_VERSION_CHECK(6,0,0) void toStdListOptimal() const; void toStdListMovable() const; void toStdListComplex() const; +#endif void toVectorOptimal() const; void toVectorMovable() const; void toVectorComplex() const; @@ -427,7 +429,9 @@ private: template void takeFirst() const; template void takeLast() const; template void toSet() const; +#if QT_VERSION < QT_VERSION_CHECK(6,0,0) template void toStdList() const; +#endif template void toVector() const; template void value() const; @@ -1633,6 +1637,7 @@ void tst_QList::toSetComplex() const QCOMPARE(liveCount, Complex::getLiveCount()); } +#if QT_VERSION < QT_VERSION_CHECK(6,0,0) template void tst_QList::toStdList() const { @@ -1669,6 +1674,7 @@ void tst_QList::toStdListComplex() const toStdList(); QCOMPARE(liveCount, Complex::getLiveCount()); } +#endif template void tst_QList::toVector() const diff --git a/tests/auto/corelib/tools/qvector/tst_qvector.cpp b/tests/auto/corelib/tools/qvector/tst_qvector.cpp index 172b03a445..f81ce11510 100644 --- a/tests/auto/corelib/tools/qvector/tst_qvector.cpp +++ b/tests/auto/corelib/tools/qvector/tst_qvector.cpp @@ -257,7 +257,6 @@ private slots: void fromListInt() const; void fromListMovable() const; void fromListCustom() const; - void fromStdVector() const; void indexOf() const; void insertInt() const; void insertMovable() const; @@ -296,7 +295,10 @@ private slots: void swapMovable() const; void swapCustom() const; void toList() const; +#if QT_VERSION < QT_VERSION_CHECK(6,0,0) + void fromStdVector() const; void toStdVector() const; +#endif void value() const; void testOperators() const; @@ -1426,6 +1428,7 @@ void tst_QVector::fromListCustom() const QCOMPARE(instancesCount, Custom::counter.loadAcquire()); } +#if QT_VERSION < QT_VERSION_CHECK(6,0,0) void tst_QVector::fromStdVector() const { // stl = :( @@ -1439,6 +1442,7 @@ void tst_QVector::fromStdVector() const // test it converts ok QCOMPARE(myvec, QVector() << "aaa" << "bbb" << "ninjas" << "pirates"); } +#endif void tst_QVector::indexOf() const { @@ -2331,6 +2335,7 @@ void tst_QVector::toList() const QCOMPARE(myvec, QVector() << "A" << "B" << "C"); } +#if QT_VERSION < QT_VERSION_CHECK(6,0,0) void tst_QVector::toStdVector() const { QVector myvec; @@ -2343,6 +2348,7 @@ void tst_QVector::toStdVector() const QCOMPARE(myvec, QVector() << "A" << "B" << "C"); } +#endif void tst_QVector::value() const {