QMap/QHash: s/QPair/std::pair/

Also port from qMakePair to just braced initialization using CTAD.

Task-number: QTBUG-115841
Change-Id: Ib0ad55d7110521e34004dc9050022f9c0046722e
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
(cherry picked from commit 0d1575828015f99a495af84fb7de3746c7f61717)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Marc Mutz 2023-12-12 09:20:30 +01:00 committed by Qt Cherry-pick Bot
parent 8cba66e91d
commit cab0d26c45
5 changed files with 24 additions and 24 deletions

View File

@ -1783,8 +1783,8 @@ size_t qHash(long double key, size_t seed) noexcept
Constructs a hash with a copy of each of the elements in the iterator range
[\a begin, \a end). Either the elements iterated by the range must be
objects with \c{first} and \c{second} data members (like \c{QPair},
\c{std::pair}, etc.) convertible to \c Key and to \c T respectively; or the
objects with \c{first} and \c{second} data members (like \c{std::pair}),
convertible to \c Key and to \c T respectively; or the
iterators must have \c{key()} and \c{value()} member functions, returning a
key convertible to \c Key and a value convertible to \c T respectively.
*/
@ -2362,7 +2362,7 @@ size_t qHash(long double key, size_t seed) noexcept
returns \c false.
*/
/*! \fn template <class Key, class T> QPair<iterator, iterator> QMultiHash<Key, T>::equal_range(const Key &key)
/*! \fn template <class Key, class T> std::pair<iterator, iterator> QMultiHash<Key, T>::equal_range(const Key &key)
\since 5.7
Returns a pair of iterators delimiting the range of values \c{[first, second)}, that
@ -2370,7 +2370,7 @@ size_t qHash(long double key, size_t seed) noexcept
*/
/*!
\fn template <class Key, class T> QPair<const_iterator, const_iterator> QMultiHash<Key, T>::equal_range(const Key &key) const
\fn template <class Key, class T> std::pair<const_iterator, const_iterator> QMultiHash<Key, T>::equal_range(const Key &key) const
\overload
\since 5.7
*/
@ -2955,8 +2955,8 @@ size_t qHash(long double key, size_t seed) noexcept
Constructs a multi-hash with a copy of each of the elements in the iterator range
[\a begin, \a end). Either the elements iterated by the range must be
objects with \c{first} and \c{second} data members (like \c{QPair},
\c{std::pair}, etc.) convertible to \c Key and to \c T respectively; or the
objects with \c{first} and \c{second} data members (like \c{std::pair}),
convertible to \c Key and to \c T respectively; or the
iterators must have \c{key()} and \c{value()} member functions, returning a
key convertible to \c Key and a value convertible to \c T respectively.
*/

View File

@ -1234,22 +1234,22 @@ public:
return i;
}
QPair<iterator, iterator> equal_range(const Key &key)
std::pair<iterator, iterator> equal_range(const Key &key)
{
auto first = find(key);
auto second = first;
if (second != iterator())
++second;
return qMakePair(first, second);
return {first, second};
}
QPair<const_iterator, const_iterator> equal_range(const Key &key) const noexcept
std::pair<const_iterator, const_iterator> equal_range(const Key &key) const noexcept
{
auto first = find(key);
auto second = first;
if (second != iterator())
++second;
return qMakePair(first, second);
return {first, second};
}
typedef iterator Iterator;
@ -2125,26 +2125,26 @@ public:
return *this;
}
QPair<iterator, iterator> equal_range(const Key &key)
std::pair<iterator, iterator> equal_range(const Key &key)
{
const auto copy = isDetached() ? QMultiHash() : *this; // keep 'key' alive across the detach
detach();
auto pair = std::as_const(*this).equal_range(key);
return qMakePair(iterator(pair.first.i), iterator(pair.second.i));
return {iterator(pair.first.i), iterator(pair.second.i)};
}
QPair<const_iterator, const_iterator> equal_range(const Key &key) const noexcept
std::pair<const_iterator, const_iterator> equal_range(const Key &key) const noexcept
{
if (!d)
return qMakePair(end(), end());
return {end(), end()};
auto bucket = d->findBucket(key);
if (bucket.isUnused())
return qMakePair(end(), end());
return {end(), end()};
auto it = bucket.toIterator(d);
auto end = it;
++end;
return qMakePair(const_iterator(it), const_iterator(end));
return {const_iterator(it), const_iterator(end)};
}
private:

View File

@ -762,7 +762,7 @@ public:
return isEmpty();
}
QPair<iterator, iterator> equal_range(const Key &akey)
std::pair<iterator, iterator> equal_range(const Key &akey)
{
const auto copy = d.isShared() ? *this : QMap(); // keep `key` alive across the detach
detach();
@ -770,7 +770,7 @@ public:
return {iterator(result.first), iterator(result.second)};
}
QPair<const_iterator, const_iterator> equal_range(const Key &akey) const
std::pair<const_iterator, const_iterator> equal_range(const Key &akey) const
{
if (!d)
return {};
@ -1492,7 +1492,7 @@ public:
// STL compatibility
inline bool empty() const { return isEmpty(); }
QPair<iterator, iterator> equal_range(const Key &akey)
std::pair<iterator, iterator> equal_range(const Key &akey)
{
const auto copy = d.isShared() ? *this : QMultiMap(); // keep `key` alive across the detach
detach();
@ -1500,7 +1500,7 @@ public:
return {iterator(result.first), iterator(result.second)};
}
QPair<const_iterator, const_iterator> equal_range(const Key &akey) const
std::pair<const_iterator, const_iterator> equal_range(const Key &akey) const
{
if (!d)
return {};

View File

@ -818,14 +818,14 @@
*/
/*!
\fn template <class Key, class T> QPair<typename QMap<Key, T>::iterator, typename QMap<Key, T>::iterator> QMap<Key, T>::equal_range(const Key &key)
\fn template <class Key, class T> std::pair<typename QMap<Key, T>::iterator, typename QMap<Key, T>::iterator> QMap<Key, T>::equal_range(const Key &key)
Returns a pair of iterators delimiting the range of values \c{[first, second)}, that
are stored under \a key.
*/
/*!
\fn template <class Key, class T> QPair<typename QMap<Key, T>::const_iterator, typename QMap<Key, T>::const_iterator> QMap<Key, T>::equal_range(const Key &key) const
\fn template <class Key, class T> std::pair<typename QMap<Key, T>::const_iterator, typename QMap<Key, T>::const_iterator> QMap<Key, T>::equal_range(const Key &key) const
\overload
\since 5.6
*/

View File

@ -934,14 +934,14 @@
*/
/*!
\fn template <class Key, class T> QPair<typename QMultiMap<Key, T>::iterator, typename QMultiMap<Key, T>::iterator> QMultiMap<Key, T>::equal_range(const Key &key)
\fn template <class Key, class T> std::pair<typename QMultiMap<Key, T>::iterator, typename QMultiMap<Key, T>::iterator> QMultiMap<Key, T>::equal_range(const Key &key)
Returns a pair of iterators delimiting the range of values \c{[first, second)}, that
are stored under \a key.
*/
/*!
\fn template <class Key, class T> QPair<typename QMultiMap<Key, T>::const_iterator, typename QMultiMap<Key, T>::const_iterator> QMultiMap<Key, T>::equal_range(const Key &key) const
\fn template <class Key, class T> std::pair<typename QMultiMap<Key, T>::const_iterator, typename QMultiMap<Key, T>::const_iterator> QMultiMap<Key, T>::equal_range(const Key &key) const
\overload
\since 5.6
*/