diff --git a/src/corelib/tools/qlist.cpp b/src/corelib/tools/qlist.cpp index 17aba8035b..0eed4a619e 100644 --- a/src/corelib/tools/qlist.cpp +++ b/src/corelib/tools/qlist.cpp @@ -47,6 +47,23 @@ 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 and + ### QVector respectively. +*/ + +#if defined(Q_CC_MSVC) && defined(QT_BUILD_CORE_LIB) +QT_BEGIN_INCLUDE_NAMESPACE +#include +QT_END_INCLUDE_NAMESPACE + +template class Q_CORE_EXPORT QVector; +template class Q_CORE_EXPORT QVector; +#endif + + /* QList as an array-list combines the easy-of-use of a random access interface with fast list operations and the low memory diff --git a/src/corelib/tools/qlist.h b/src/corelib/tools/qlist.h index 49ccbc9c9f..073993ee56 100644 --- a/src/corelib/tools/qlist.h +++ b/src/corelib/tools/qlist.h @@ -45,6 +45,7 @@ #include #include #include +#include #include #include @@ -1051,6 +1052,37 @@ inline int QList::count_impl(const T &t, QListData::ArrayCompatibleLayout) co t)); } +template +Q_OUTOFLINE_TEMPLATE QVector QList::toVector() const +{ + QVector result(size()); + for (int i = 0; i < size(); ++i) + result[i] = at(i); + return result; +} + +template +QList QList::fromVector(const QVector &vector) +{ + return vector.toList(); +} + +template +Q_OUTOFLINE_TEMPLATE QList QVector::toList() const +{ + QList result; + result.reserve(size()); + for (int i = 0; i < size(); ++i) + result.append(at(i)); + return result; +} + +template +QVector QVector::fromList(const QList &list) +{ + return list.toVector(); +} + Q_DECLARE_SEQUENTIAL_ITERATOR(List) Q_DECLARE_MUTABLE_SEQUENTIAL_ITERATOR(List) diff --git a/src/corelib/tools/qvector.h b/src/corelib/tools/qvector.h index 30fd7b2865..778bcb3745 100644 --- a/src/corelib/tools/qvector.h +++ b/src/corelib/tools/qvector.h @@ -42,7 +42,6 @@ #include #include -#include #include #include #include @@ -968,37 +967,6 @@ Q_OUTOFLINE_TEMPLATE QVector QVector::mid(int pos, int len) const return midResult; } -template -Q_OUTOFLINE_TEMPLATE QList QVector::toList() const -{ - QList result; - result.reserve(size()); - for (int i = 0; i < size(); ++i) - result.append(at(i)); - return result; -} - -template -Q_OUTOFLINE_TEMPLATE QVector QList::toVector() const -{ - QVector result(size()); - for (int i = 0; i < size(); ++i) - result[i] = at(i); - return result; -} - -template -QVector QVector::fromList(const QList &list) -{ - return list.toVector(); -} - -template -QList QList::fromVector(const QVector &vector) -{ - return vector.toList(); -} - Q_DECLARE_SEQUENTIAL_ITERATOR(Vector) Q_DECLARE_MUTABLE_SEQUENTIAL_ITERATOR(Vector) @@ -1046,20 +1014,12 @@ inline bool operator>=(const QVector &lhs, const QVector &rhs) ### QVector respectively. */ -#ifdef Q_CC_MSVC +#if defined(Q_CC_MSVC) && !defined(QT_BUILD_CORE_LIB) QT_BEGIN_INCLUDE_NAMESPACE #include QT_END_INCLUDE_NAMESPACE - -#ifndef Q_TEMPLATE_EXTERN -#if defined(QT_BUILD_CORE_LIB) -#define Q_TEMPLATE_EXTERN -#else -#define Q_TEMPLATE_EXTERN extern -#endif -#endif -Q_TEMPLATE_EXTERN template class Q_CORE_EXPORT QVector; -Q_TEMPLATE_EXTERN template class Q_CORE_EXPORT QVector; +extern template class Q_CORE_EXPORT QVector; +extern template class Q_CORE_EXPORT QVector; #endif QVector QStringView::toUcs4() const { return QtPrivate::convertToUcs4(*this); }