summaryrefslogtreecommitdiffstats
path: root/src/corelib/tools/qvarlengtharray.h
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@kdab.com>2012-05-24 08:26:46 +0200
committerQt by Nokia <qt-info@nokia.com>2012-08-30 02:28:51 +0200
commitc2f10f915fd6fa4d38c83a4c8b0e1c63a254643a (patch)
tree2e74c6e8ba593b044faefceea2de423a54910173 /src/corelib/tools/qvarlengtharray.h
parent6276427438d8247348f3bc9643d915d725f229d8 (diff)
QVarLengthArray: C++11-ify insert/erase signatures
In C++11, container insert and erase operations take const_iterators instead of iterators. This is a bug fix compared to C++98, where the mere lookup step of a lookup-or-insert operation had to be done using (mutable) iterators, which is particularly worrisome for Qt containers that are implicitly shared, because of the unneeded detach in the positive case. QVarLengthArray is not implicitly shared, but for consistency, the signatures should be changed here, too. The reason this commit contains only the change to QVarLengthArray is that this is by far the easiest container. The implictly shared containers are harder, because detaching invalidates other iterators (more than the sister STL container would). Change-Id: Ib3d98360bfe376b782b9d1283c5fa3555e8a719e Reviewed-by: João Abecasis <joao.abecasis@nokia.com> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/tools/qvarlengtharray.h')
-rw-r--r--src/corelib/tools/qvarlengtharray.h12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/corelib/tools/qvarlengtharray.h b/src/corelib/tools/qvarlengtharray.h
index 58b26be4a9..ba24541d2d 100644
--- a/src/corelib/tools/qvarlengtharray.h
+++ b/src/corelib/tools/qvarlengtharray.h
@@ -167,10 +167,10 @@ public:
inline const_iterator end() const { return ptr + s; }
inline const_iterator cend() const { return ptr + s; }
inline const_iterator constEnd() const { return ptr + s; }
- iterator insert(iterator before, int n, const T &x);
- inline iterator insert(iterator before, const T &x) { return insert(before, 1, x); }
- iterator erase(iterator begin, iterator end);
- inline iterator erase(iterator pos) { return erase(pos, pos+1); }
+ iterator insert(const_iterator before, int n, const T &x);
+ inline iterator insert(const_iterator before, const T &x) { return insert(before, 1, x); }
+ iterator erase(const_iterator begin, const_iterator end);
+ inline iterator erase(const_iterator pos) { return erase(pos, pos+1); }
private:
friend class QPodList<T, Prealloc>;
@@ -338,7 +338,7 @@ inline void QVarLengthArray<T, Prealloc>::replace(int i, const T &t)
template <class T, int Prealloc>
-Q_OUTOFLINE_TEMPLATE typename QVarLengthArray<T, Prealloc>::iterator QVarLengthArray<T, Prealloc>::insert(iterator before, size_type n, const T &t)
+Q_OUTOFLINE_TEMPLATE typename QVarLengthArray<T, Prealloc>::iterator QVarLengthArray<T, Prealloc>::insert(const_iterator before, size_type n, const T &t)
{
int offset = int(before - ptr);
if (n != 0) {
@@ -365,7 +365,7 @@ Q_OUTOFLINE_TEMPLATE typename QVarLengthArray<T, Prealloc>::iterator QVarLengthA
}
template <class T, int Prealloc>
-Q_OUTOFLINE_TEMPLATE typename QVarLengthArray<T, Prealloc>::iterator QVarLengthArray<T, Prealloc>::erase(iterator abegin, iterator aend)
+Q_OUTOFLINE_TEMPLATE typename QVarLengthArray<T, Prealloc>::iterator QVarLengthArray<T, Prealloc>::erase(const_iterator abegin, const_iterator aend)
{
int f = int(abegin - ptr);
int l = int(aend - ptr);