Compile in strict-iterator mode under MSVC

MSVC doesn't like operator->() returning a pointer to
non-aggregate. So we must make sure that the expanded code does not
try to call it by doing:
  abegin->~T();

Instead, we make an implicit call to operator T*() with that
static_cast<T* >. If abegin is a non-strict iterator, it's already
a T*, so the static_cast is a no-op.

qvector.h(645) : error C2839: invalid return type 'int *' for overloaded 'operator ->'

Change-Id: I06f983bab7677cb60ef3913cdce349e26896bfb6
Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
This commit is contained in:
Thiago Macieira 2013-09-05 16:59:46 -07:00 committed by The Qt Project
parent 018c4850c9
commit ba43b70132

View File

@ -634,7 +634,7 @@ typename QVector<T>::iterator QVector<T>::erase(iterator abegin, iterator aend)
iterator moveEnd = d->end();
while (moveBegin != moveEnd) {
if (QTypeInfo<T>::isComplex)
abegin->~T();
static_cast<T *>(abegin)->~T();
new (abegin++) T(*moveBegin++);
}
if (abegin < d->end()) {