summaryrefslogtreecommitdiffstats
path: root/src/corelib/tools/qvector.h
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@intel.com>2012-05-31 12:35:39 +0200
committerQt by Nokia <qt-info@nokia.com>2012-06-01 12:27:37 +0200
commit5a447502b539c10a399f9d6579efbae6ef5ca9f0 (patch)
tree6e0aede2444cb68fe1f26d410ac0c43bf0239e66 /src/corelib/tools/qvector.h
parent9c5a77f0ef0b2ace0b11719142115eded4a7c05e (diff)
Fix the QVector build with C++11 initialiser lists
Initialiser lists were not tested before in the QVector rewrite, so the older malloc call was left behind. Also, std::initializer_list has const iterators returning const data and broke the build in a few places where const qualifiers were missing. Change-Id: I3c04e58361989aa7438621cda63c7df457d7dad8 Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@nokia.com>
Diffstat (limited to 'src/corelib/tools/qvector.h')
-rw-r--r--src/corelib/tools/qvector.h6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/corelib/tools/qvector.h b/src/corelib/tools/qvector.h
index 06c269b8dc..88a6744d11 100644
--- a/src/corelib/tools/qvector.h
+++ b/src/corelib/tools/qvector.h
@@ -223,7 +223,7 @@ private:
void realloc(const int size, const int alloc, QArrayData::AllocationOptions options = QArrayData::Default);
void free(Data *d);
void defaultConstruct(T *from, T *to);
- void copyConstruct(T *srcFrom, T *srcTo, T *dstFrom);
+ void copyConstruct(const T *srcFrom, const T *srcTo, T *dstFrom);
void destruct(T *from, T *to);
class AlignmentDummy { Data header; T array[1]; };
@@ -250,7 +250,7 @@ void QVector<T>::defaultConstruct(T *from, T *to)
#endif
template <typename T>
-void QVector<T>::copyConstruct(T *srcFrom, T *srcTo, T *dstFrom)
+void QVector<T>::copyConstruct(const T *srcFrom, const T *srcTo, T *dstFrom)
{
if (QTypeInfo<T>::isComplex) {
while (srcFrom != srcTo)
@@ -412,7 +412,7 @@ QVector<T>::QVector(int asize, const T &t)
template <typename T>
QVector<T>::QVector(std::initializer_list<T> args)
{
- d = malloc(int(args.size()));
+ d = Data::allocate(args.size());
// 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());