summaryrefslogtreecommitdiffstats
path: root/src/corelib/tools/qvector.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/corelib/tools/qvector.h')
-rw-r--r--src/corelib/tools/qvector.h26
1 files changed, 13 insertions, 13 deletions
diff --git a/src/corelib/tools/qvector.h b/src/corelib/tools/qvector.h
index 07c66bc393..c00bd07a72 100644
--- a/src/corelib/tools/qvector.h
+++ b/src/corelib/tools/qvector.h
@@ -128,6 +128,7 @@ public:
T &operator[](int i);
const T &operator[](int i) const;
void append(const T &t);
+ inline void append(const QVector<T> &l) { *this += l; }
void prepend(const T &t);
void insert(int i, const T &t);
void insert(int i, int n, const T &t);
@@ -327,9 +328,11 @@ inline QVector<T>::QVector(const QVector<T> &v)
} else {
if (v.d->capacityReserved) {
d = Data::allocate(v.d->alloc);
+ Q_CHECK_PTR(d);
d->capacityReserved = true;
} else {
d = Data::allocate(v.d->size);
+ Q_CHECK_PTR(d);
}
if (d->alloc) {
copyConstruct(v.d->begin(), v.d->end(), d->begin());
@@ -439,6 +442,7 @@ QVector<T>::QVector(int asize)
Q_ASSERT_X(asize >= 0, "QVector::QVector", "Size must be greater than or equal to 0.");
if (Q_LIKELY(asize > 0)) {
d = Data::allocate(asize);
+ Q_CHECK_PTR(d);
d->size = asize;
defaultConstruct(d->begin(), d->end());
} else {
@@ -452,6 +456,7 @@ QVector<T>::QVector(int asize, const T &t)
Q_ASSERT_X(asize >= 0, "QVector::QVector", "Size must be greater than or equal to 0.");
if (asize > 0) {
d = Data::allocate(asize);
+ Q_CHECK_PTR(d);
d->size = asize;
T* i = d->end();
while (i != d->begin())
@@ -467,6 +472,7 @@ QVector<T>::QVector(std::initializer_list<T> args)
{
if (args.size() > 0) {
d = Data::allocate(args.size());
+ Q_CHECK_PTR(d);
// std::initializer_list<T>::iterator is guaranteed to be
// const T* ([support.initlist]/1), so can be memcpy'ed away from by copyConstruct
copyConstruct(args.begin(), args.end(), d->begin());
@@ -707,13 +713,10 @@ bool QVector<T>::operator==(const QVector<T> &v) const
return true;
if (d->size != v.d->size)
return false;
- T* b = d->begin();
- T* i = b + d->size;
- T* j = v.d->end();
- while (i != b)
- if (!(*--i == *--j))
- return false;
- return true;
+ const T *vb = v.d->begin();
+ const T *b = d->begin();
+ const T *e = d->end();
+ return std::equal(b, e, vb);
}
template <typename T>
@@ -791,12 +794,9 @@ int QVector<T>::lastIndexOf(const T &t, int from) const
template <typename T>
bool QVector<T>::contains(const T &t) const
{
- T* b = d->begin();
- T* i = d->end();
- while (i != b)
- if (*--i == t)
- return true;
- return false;
+ const T *b = d->begin();
+ const T *e = d->end();
+ return std::find(b, e, t) != e;
}
template <typename T>