From 900d4bd29f30effbb5dbb0efa96886af03839a15 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Tue, 23 Jan 2024 18:28:25 +0100 Subject: Add QtPrivate::ArrowProxy ... use it in QKeyValueIterator. This is somewhat simpler than the old QKeyValueIterator::pointer. I don't think the pointer::operator*() could have ever worked, because it returns value_type&, but is const. That leaves the defaulted copy and move SMFs as a difference (ArrowProxy is using aggregate initialization, so doesn't need any), and the fact that operator->() is const. Change-Id: I80b9c5f696de6ae30f3939166b205b9213eac57e Reviewed-by: Thiago Macieira --- src/corelib/tools/qiterator.h | 21 +++------------------ 1 file changed, 3 insertions(+), 18 deletions(-) (limited to 'src/corelib/tools/qiterator.h') diff --git a/src/corelib/tools/qiterator.h b/src/corelib/tools/qiterator.h index ab3d71f760..8a2b493ef4 100644 --- a/src/corelib/tools/qiterator.h +++ b/src/corelib/tools/qiterator.h @@ -5,6 +5,7 @@ #define QITERATOR_H #include +#include QT_BEGIN_NAMESPACE @@ -253,26 +254,10 @@ public: return std::pair(i.key(), i.value()); } - struct pointer - { - pointer(value_type &&r_) : r(std::move(r_)) { } - - pointer() = default; - pointer(const pointer &other) = default; - pointer(pointer &&other) = default; - pointer &operator=(const pointer &other) = default; - pointer &operator=(pointer &&other) = default; - - value_type &operator*() const { return r; } - - value_type r; - const value_type *operator->() const { - return &r; - } - }; + using pointer = QtPrivate::ArrowProxy; pointer operator->() const { - return pointer(std::pair(i.key(), i.value())); + return pointer{std::pair(i.key(), i.value())}; } friend bool operator==(QKeyValueIterator lhs, QKeyValueIterator rhs) noexcept { return lhs.i == rhs.i; } -- cgit v1.2.3