From fb65b32d7621f065ec854f1e72828720bffb3b39 Mon Sep 17 00:00:00 2001 From: Mitch Curtis Date: Mon, 7 Sep 2020 15:57:15 +0200 Subject: Add qHash implementation for QPoint MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit [ChangeLog][QtCore][QPoint] Added qHash() implementation. Change-Id: I65332e7aafab53af40a6e11457b9b457196d584c Fixes: QTBUG-86457 Reviewed-by: Thorbjørn Lindeijer Reviewed-by: Thiago Macieira --- src/corelib/tools/qpoint.cpp | 14 ++++++++++++++ src/corelib/tools/qpoint.h | 1 + 2 files changed, 15 insertions(+) (limited to 'src') diff --git a/src/corelib/tools/qpoint.cpp b/src/corelib/tools/qpoint.cpp index 432fb33297..eca1b5a0ac 100644 --- a/src/corelib/tools/qpoint.cpp +++ b/src/corelib/tools/qpoint.cpp @@ -41,6 +41,7 @@ #include "qdatastream.h" #include +#include QT_BEGIN_NAMESPACE @@ -483,6 +484,19 @@ QDebug operator<<(QDebug dbg, const QPointF &p) } #endif +/*! + \fn size_t qHash(QPoint key, size_t seed = 0) + \relates QHash + \since 6.0 + + Returns the hash value for the \a key, using \a seed to seed the + calculation. +*/ +size_t qHash(QPoint key, size_t seed) noexcept +{ + return qHashMulti(seed, key.x(), key.y()); +} + /*! \class QPointF \inmodule QtCore diff --git a/src/corelib/tools/qpoint.h b/src/corelib/tools/qpoint.h index 725787265f..e854e77198 100644 --- a/src/corelib/tools/qpoint.h +++ b/src/corelib/tools/qpoint.h @@ -214,6 +214,7 @@ constexpr inline const QPoint operator/(const QPoint &p, qreal c) Q_CORE_EXPORT QDebug operator<<(QDebug, const QPoint &); #endif +Q_CORE_EXPORT size_t qHash(QPoint key, size_t seed = 0) noexcept; -- cgit v1.2.3