From e89b2f72c7147e46dcf606c3dcc507e2ae2841ce Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Wed, 10 Jul 2019 19:46:45 +0200 Subject: Centralize the MSVC work-around for std::is_permutation There's currently only one user, but another one is coming up, so apply DRY and centralize the work-around for the MSVC warning C4996 on use of 3-arg STL algorithms in one place. The code is prepared to handle other algorithms with ease, should any more crop up. Change-Id: Ia881888d6a2b5286c6d8d823bc2b76788efad624 Reviewed-by: Thiago Macieira --- src/corelib/tools/qhash.h | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) (limited to 'src/corelib/tools') diff --git a/src/corelib/tools/qhash.h b/src/corelib/tools/qhash.h index ee754a79d5..236e433101 100644 --- a/src/corelib/tools/qhash.h +++ b/src/corelib/tools/qhash.h @@ -981,22 +981,8 @@ Q_OUTOFLINE_TEMPLATE bool QHash::operator==(const QHash &other) const return false; // Keys in the ranges are equal by construction; this checks only the values. - // - // 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(thisEqualRangeStart, it, otherEqualRange.first -#ifdef Q_CC_MSVC - , otherEqualRange.second -#endif - )) { + if (!qt_is_permutation(thisEqualRangeStart, it, otherEqualRange.first, otherEqualRange.second)) return false; - } } return true; -- cgit v1.2.3