diff options
Diffstat (limited to 'src/corelib/tools/qlist.h')
-rw-r--r-- | src/corelib/tools/qlist.h | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/src/corelib/tools/qlist.h b/src/corelib/tools/qlist.h index 77d8df4a88..dfb8a8a4ab 100644 --- a/src/corelib/tools/qlist.h +++ b/src/corelib/tools/qlist.h @@ -46,6 +46,7 @@ #include <QtCore/qarraydata.h> #include <QtCore/qhashfunctions.h> #include <QtCore/qvector.h> +#include <QtCore/qcontainertools_impl.h> #include <iterator> #include <list> @@ -169,9 +170,11 @@ public: inline void swap(QList<T> &other) noexcept { qSwap(d, other.d); } #ifdef Q_COMPILER_INITIALIZER_LISTS inline QList(std::initializer_list<T> args) - : d(const_cast<QListData::Data *>(&QListData::shared_null)) - { reserve(int(args.size())); std::copy(args.begin(), args.end(), std::back_inserter(*this)); } + : QList(args.begin(), args.end()) {} #endif + template <typename InputIterator, QtPrivate::IfIsInputIterator<InputIterator> = true> + QList(InputIterator first, InputIterator last); + bool operator==(const QList<T> &l) const; inline bool operator!=(const QList<T> &l) const { return !(*this == l); } @@ -843,6 +846,15 @@ Q_OUTOFLINE_TEMPLATE QList<T>::~QList() } template <typename T> +template <typename InputIterator, QtPrivate::IfIsInputIterator<InputIterator>> +QList<T>::QList(InputIterator first, InputIterator last) + : QList() +{ + QtPrivate::reserveIfForwardIterator(this, first, last); + std::copy(first, last, std::back_inserter(*this)); +} + +template <typename T> Q_OUTOFLINE_TEMPLATE bool QList<T>::operator==(const QList<T> &l) const { if (d == l.d) |