QMetaType: Fix equality comparison of type-erased iterators.

Task-number: QTBUG-33997

Change-Id: I0d4da562540df0e3732769881ba124cb980f6b82
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
bb10
Stephen Kelly 2013-12-12 17:45:34 +01:00 committed by The Qt Project
parent 0da7e0fa8f
commit b7cb0613f0
1 changed files with 12 additions and 2 deletions

View File

@ -808,6 +808,11 @@ struct IteratorOwner
{
return &*it;
}
static bool equal(void * const *it, void * const *other)
{
return *static_cast<const_iterator*>(*it) == *static_cast<const_iterator*>(*other);
}
};
template<typename value_type>
struct IteratorOwner<const value_type*>
@ -841,6 +846,11 @@ struct IteratorOwner<const value_type*>
{
return it;
}
static bool equal(void * const *it, void * const *other)
{
return static_cast<value_type*>(*it) == static_cast<value_type*>(*other);
}
};
enum IteratorCapability
@ -942,7 +952,7 @@ public:
template<class T>
static bool equalIterImpl(void * const *iterator, void * const *other)
{ return *static_cast<typename T::const_iterator*>(*iterator) == *static_cast<typename T::const_iterator*>(*other); }
{ return IteratorOwner<typename T::const_iterator>::equal(iterator, other); }
template<class T>
static VariantData getImpl(void * const *iterator, int metaTypeId, uint flags)
@ -1126,7 +1136,7 @@ public:
template<class T>
static bool equalIterImpl(void * const *iterator, void * const *other)
{ return *static_cast<typename T::const_iterator*>(*iterator) == *static_cast<typename T::const_iterator*>(*other); }
{ return IteratorOwner<typename T::const_iterator>::equal(iterator, other); }
template<class T>
static void copyIterImpl(void **dest, void * const * src)