summaryrefslogtreecommitdiffstats
path: root/src/corelib/tools/qhash.cpp
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@kdab.com>2019-07-08 21:25:55 +0200
committerMarc Mutz <marc.mutz@kdab.com>2020-03-05 13:24:32 +0100
commitbd84e8d63e6fc2e05df21e8c60d56c01b5fa0674 (patch)
tree84180408cd0c2ec394c973264f97c8cc809e044a /src/corelib/tools/qhash.cpp
parentdfaca09e85a49d2983bb89893bfbe1ba4c19eab4 (diff)
QHash/QMap: don't return const from value(), key()
... it breaks move semantics. We can change these, since they're templates and a short survey shows that no-one in Qt was crazy enough to inherit an exported class from QHash or QMap. Otherwise this would be BiC on MSVC, which encodes the return type. There's also no safety benefit here, as none of the overloads returns by reference, so users cannot expect map.value(key).mutate() to have an effect on the element in the container. In this, key() and value() differ from op[], which also returns const, but whose overload returns a reference. op[] is therefore not proposed here. [ChangeLog][QtCore][QHash/QMultiHash/QMap/QMultiMap] The value() and key() member functions now return T (was: const T), enabling move semantics on their return values. Change-Id: I0e5f53f9834caad458e3bde27f1daacbb4bac71b Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Diffstat (limited to 'src/corelib/tools/qhash.cpp')
-rw-r--r--src/corelib/tools/qhash.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/corelib/tools/qhash.cpp b/src/corelib/tools/qhash.cpp
index 7ebc374d9f..1e5af7e0ce 100644
--- a/src/corelib/tools/qhash.cpp
+++ b/src/corelib/tools/qhash.cpp
@@ -1449,7 +1449,7 @@ uint qHash(long double key, uint seed) noexcept
\sa count(), QMultiHash::contains()
*/
-/*! \fn template <class Key, class T> const T QHash<Key, T>::value(const Key &key) const
+/*! \fn template <class Key, class T> T QHash<Key, T>::value(const Key &key) const
Returns the value associated with the \a key.
@@ -1461,7 +1461,7 @@ uint qHash(long double key, uint seed) noexcept
\sa key(), values(), contains(), operator[]()
*/
-/*! \fn template <class Key, class T> const T QHash<Key, T>::value(const Key &key, const T &defaultValue) const
+/*! \fn template <class Key, class T> T QHash<Key, T>::value(const Key &key, const T &defaultValue) const
\overload
If the hash contains no item with the given \a key, the function returns