diff options
author | Liang Qi <liang.qi@theqtcompany.com> | 2015-03-24 07:37:43 +0100 |
---|---|---|
committer | Liang Qi <liang.qi@theqtcompany.com> | 2015-03-24 07:38:02 +0100 |
commit | 135ebe4f3d268121047fdbfee49f2dd52006165e (patch) | |
tree | 6b303103f36e69e29cfa860b8b7afc584c55d6f3 /src/corelib/tools/qvarlengtharray.h | |
parent | e7feb956280105113b3e58f12e5f32f54199a95a (diff) | |
parent | 1e8f50a8d069c97ea6a4f00d664c12e594884f54 (diff) |
Merge remote-tracking branch 'origin/5.5' into dev
Change-Id: If5d2e621c2fa5476c3ab687a3f4620c54fc3b32e
Diffstat (limited to 'src/corelib/tools/qvarlengtharray.h')
-rw-r--r-- | src/corelib/tools/qvarlengtharray.h | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/src/corelib/tools/qvarlengtharray.h b/src/corelib/tools/qvarlengtharray.h index 54d97d8762..95cd0447d8 100644 --- a/src/corelib/tools/qvarlengtharray.h +++ b/src/corelib/tools/qvarlengtharray.h @@ -42,6 +42,9 @@ #include <string.h> #include <stdlib.h> #include <algorithm> +#ifdef Q_COMPILER_INITIALIZER_LISTS +#include <initializer_list> +#endif QT_BEGIN_NAMESPACE @@ -62,6 +65,14 @@ 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)) + { + append(args.begin(), args.size()); + } +#endif + inline ~QVarLengthArray() { if (QTypeInfo<T>::isComplex) { T *i = ptr + s; @@ -457,11 +468,10 @@ bool operator==(const QVarLengthArray<T, Prealloc1> &l, const QVarLengthArray<T, { if (l.size() != r.size()) return false; - for (int i = 0; i < l.size(); i++) { - if (l.at(i) != r.at(i)) - return false; - } - return true; + const T *rb = r.begin(); + const T *b = l.begin(); + const T *e = l.end(); + return std::equal(b, e, rb); } template <typename T, int Prealloc1, int Prealloc2> |