diff options
Diffstat (limited to 'src/corelib/tools/qvarlengtharray.h')
-rw-r--r-- | src/corelib/tools/qvarlengtharray.h | 33 |
1 files changed, 17 insertions, 16 deletions
diff --git a/src/corelib/tools/qvarlengtharray.h b/src/corelib/tools/qvarlengtharray.h index 597e7464cb..01fc63b677 100644 --- a/src/corelib/tools/qvarlengtharray.h +++ b/src/corelib/tools/qvarlengtharray.h @@ -43,15 +43,14 @@ #include <QtCore/qcontainerfwd.h> #include <QtCore/qglobal.h> #include <QtCore/qalgorithms.h> +#include <QtCore/qcontainertools_impl.h> -#include <new> -#include <string.h> -#include <stdlib.h> #include <algorithm> -#ifdef Q_COMPILER_INITIALIZER_LISTS #include <initializer_list> -#endif #include <iterator> +#include <new> +#include <string.h> +#include <stdlib.h> QT_BEGIN_NAMESPACE @@ -69,14 +68,18 @@ public: append(other.constData(), other.size()); } -#ifdef Q_COMPILER_INITIALIZER_LISTS QVarLengthArray(std::initializer_list<T> args) - : a(Prealloc), s(0), ptr(reinterpret_cast<T *>(array)) + : QVarLengthArray(args.begin(), args.end()) + { + } + + template <typename InputIterator, QtPrivate::IfIsInputIterator<InputIterator> = true> + inline QVarLengthArray(InputIterator first, InputIterator last) + : QVarLengthArray() { - if (args.size()) - append(args.begin(), int(args.size())); + QtPrivate::reserveIfForwardIterator(this, first, last); + std::copy(first, last, std::back_inserter(*this)); } -#endif inline ~QVarLengthArray() { if (QTypeInfo<T>::isComplex) { @@ -96,7 +99,6 @@ public: return *this; } -#ifdef Q_COMPILER_INITIALIZER_LISTS QVarLengthArray<T, Prealloc> &operator=(std::initializer_list<T> list) { resize(list.size()); @@ -104,7 +106,6 @@ public: QT_MAKE_CHECKED_ARRAY_ITERATOR(this->begin(), this->size())); return *this; } -#endif inline void removeLast() { Q_ASSERT(s > 0); @@ -570,7 +571,7 @@ bool operator!=(const QVarLengthArray<T, Prealloc1> &l, const QVarLengthArray<T, template <typename T, int Prealloc1, int Prealloc2> bool operator<(const QVarLengthArray<T, Prealloc1> &lhs, const QVarLengthArray<T, Prealloc2> &rhs) - Q_DECL_NOEXCEPT_EXPR(noexcept(std::lexicographical_compare(lhs.begin(), lhs.end(), + noexcept(noexcept(std::lexicographical_compare(lhs.begin(), lhs.end(), rhs.begin(), rhs.end()))) { return std::lexicographical_compare(lhs.begin(), lhs.end(), @@ -579,21 +580,21 @@ bool operator<(const QVarLengthArray<T, Prealloc1> &lhs, const QVarLengthArray<T template <typename T, int Prealloc1, int Prealloc2> inline bool operator>(const QVarLengthArray<T, Prealloc1> &lhs, const QVarLengthArray<T, Prealloc2> &rhs) - Q_DECL_NOEXCEPT_EXPR(noexcept(lhs < rhs)) + noexcept(noexcept(lhs < rhs)) { return rhs < lhs; } template <typename T, int Prealloc1, int Prealloc2> inline bool operator<=(const QVarLengthArray<T, Prealloc1> &lhs, const QVarLengthArray<T, Prealloc2> &rhs) - Q_DECL_NOEXCEPT_EXPR(noexcept(lhs < rhs)) + noexcept(noexcept(lhs < rhs)) { return !(lhs > rhs); } template <typename T, int Prealloc1, int Prealloc2> inline bool operator>=(const QVarLengthArray<T, Prealloc1> &lhs, const QVarLengthArray<T, Prealloc2> &rhs) - Q_DECL_NOEXCEPT_EXPR(noexcept(lhs < rhs)) + noexcept(noexcept(lhs < rhs)) { return !(lhs < rhs); } |