QMap: Use qHash SFINAE workaround with MSVC

Fixes failure to find qHash functions when building Squish. Here, QMap
is used with custom types that do not have any associated qHash
functions. It should therefore not require a qHash function to be
usable with QMap.

There is no indication in the build output where the instantiation came from. There's nothing in the output about the function it should have
called, likely because no qHash functions exists.

Amends: e1f45ad8187947e243c8247c5cbac2d884d68d55

Fixes: QTBUG-123310
Change-Id: Idb12fb6ffab06ce242c43f2c42ea7a105e8fa0f4
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
This commit is contained in:
Jøger Hansegård 2024-03-11 22:12:12 +02:00 committed by Thiago Macieira
parent c0511410e5
commit 32b0a27d56

View File

@ -783,8 +783,8 @@ private:
#ifdef Q_QDOC
friend size_t qHash(const QMap &key, size_t seed = 0);
#else
# ifdef Q_CC_GHS
// GHS tries to intantiate qHash() for the noexcept running into a
# if defined(Q_CC_GHS) || defined (Q_CC_MSVC)
// GHS and MSVC tries to intantiate qHash() for the noexcept running into a
// non-SFINAE'ed hard error... Create an artificial SFINAE context as a
// work-around:
template <typename M, std::enable_if_t<std::is_same_v<M, QMap>, bool> = true>