diff options
author | Stephen Kelly <stephen.kelly@kdab.com> | 2013-12-12 17:45:34 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-12-13 09:28:38 +0100 |
commit | b7cb0613f0dc92a5abfd7eedc44ba9f0ee310cae (patch) | |
tree | ace7fdb59e49cf870be4285667ea92d04b5baa69 /src/corelib/kernel/qmetatype.h | |
parent | 0da7e0fa8fa0f4e216899e24b3cedf1e09759628 (diff) |
QMetaType: Fix equality comparison of type-erased iterators.
Task-number: QTBUG-33997
Change-Id: I0d4da562540df0e3732769881ba124cb980f6b82
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Diffstat (limited to 'src/corelib/kernel/qmetatype.h')
-rw-r--r-- | src/corelib/kernel/qmetatype.h | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/src/corelib/kernel/qmetatype.h b/src/corelib/kernel/qmetatype.h index 986d22b5a6..745487627e 100644 --- a/src/corelib/kernel/qmetatype.h +++ b/src/corelib/kernel/qmetatype.h @@ -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) |