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>
This commit is contained in:
parent
9c5a77f0ef
commit
5a447502b5
@ -190,9 +190,9 @@ struct QTypedArrayData
|
||||
inline bool operator>(const const_iterator& other) const { return i > other.i; }
|
||||
inline bool operator>=(const const_iterator& other) const { return i >= other.i; }
|
||||
inline const_iterator &operator++() { ++i; return *this; }
|
||||
inline const_iterator operator++(int) { T *n = i; ++i; return n; }
|
||||
inline const_iterator operator++(int) { const T *n = i; ++i; return n; }
|
||||
inline const_iterator &operator--() { i--; return *this; }
|
||||
inline const_iterator operator--(int) { T *n = i; i--; return n; }
|
||||
inline const_iterator operator--(int) { const T *n = i; i--; return n; }
|
||||
inline const_iterator &operator+=(int j) { i+=j; return *this; }
|
||||
inline const_iterator &operator-=(int j) { i-=j; return *this; }
|
||||
inline const_iterator operator+(int j) const { return const_iterator(i+j); }
|
||||
|
@ -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());
|
||||
|
@ -111,8 +111,8 @@ public:
|
||||
iterator begin() { detach(); return d->begin(); }
|
||||
iterator end() { detach(); return d->end(); }
|
||||
|
||||
const_iterator begin() const { return d->begin(); }
|
||||
const_iterator end() const { return d->end(); }
|
||||
const_iterator begin() const { return d->constBegin(); }
|
||||
const_iterator end() const { return d->constEnd(); }
|
||||
|
||||
const_iterator constBegin() const { return begin(); }
|
||||
const_iterator constEnd() const { return end(); }
|
||||
|
Loading…
Reference in New Issue
Block a user