diff --git a/src/corelib/tools/qcontainertools_impl.h b/src/corelib/tools/qcontainertools_impl.h index d66705ef4d..ef73a2a69f 100644 --- a/src/corelib/tools/qcontainertools_impl.h +++ b/src/corelib/tools/qcontainertools_impl.h @@ -254,6 +254,13 @@ void q_relocate_overlap_n(T *first, N n, T *d_first) } } +template +struct ArrowProxy +{ + T t; + T *operator->() noexcept { return &t; } +}; + template using IfIsInputIterator = typename std::enable_if< std::is_convertible::iterator_category, std::input_iterator_tag>::value, 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; }