summaryrefslogtreecommitdiffstats
path: root/src/corelib/tools/qhash.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/corelib/tools/qhash.h')
-rw-r--r--src/corelib/tools/qhash.h16
1 files changed, 15 insertions, 1 deletions
diff --git a/src/corelib/tools/qhash.h b/src/corelib/tools/qhash.h
index 0b0f935b26..715acc77ce 100644
--- a/src/corelib/tools/qhash.h
+++ b/src/corelib/tools/qhash.h
@@ -959,8 +959,22 @@ Q_OUTOFLINE_TEMPLATE bool QHash<Key, T>::operator==(const QHash &other) const
return false;
// Keys in the ranges are equal by construction; this checks only the values.
- if (!std::is_permutation(it, thisEqualRangeEnd, otherEqualRange.first))
+ //
+ // When using the 3-arg std::is_permutation, MSVC will emit warning C4996,
+ // passing an unchecked iterator to a Standard Library algorithm. We don't
+ // want to suppress the warning, and we can't use stdext::make_checked_array_iterator
+ // because QHash::(const_)iterator does not work with size_t and thus will
+ // emit more warnings. Use the 4-arg std::is_permutation instead (which
+ // is supported since MSVC 2015).
+ //
+ // ### Qt 6: if C++14 library support is a mandated minimum, remove the ifdef for MSVC.
+ if (!std::is_permutation(it, thisEqualRangeEnd, otherEqualRange.first
+#if defined(Q_CC_MSVC) && _MSC_VER >= 1900
+ , otherEqualRange.second
+#endif
+ )) {
return false;
+ }
it = thisEqualRangeEnd;
}