summaryrefslogtreecommitdiffstats
path: root/src/corelib/thread/qresultstore.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/corelib/thread/qresultstore.h')
-rw-r--r--src/corelib/thread/qresultstore.h22
1 files changed, 19 insertions, 3 deletions
diff --git a/src/corelib/thread/qresultstore.h b/src/corelib/thread/qresultstore.h
index af559b7a96..f21068206f 100644
--- a/src/corelib/thread/qresultstore.h
+++ b/src/corelib/thread/qresultstore.h
@@ -46,12 +46,21 @@ public:
ResultIteratorBase operator++();
int batchSize() const;
void batchedAdvance();
+#if QT_CORE_REMOVED_SINCE(6, 8)
bool operator==(const ResultIteratorBase &other) const;
bool operator!=(const ResultIteratorBase &other) const;
+#endif
bool isVector() const;
bool canIncrementVectorIndex() const;
bool isValid() const;
+private:
+ friend bool comparesEqual(const ResultIteratorBase &lhs,
+ const ResultIteratorBase &rhs) noexcept
+ {
+ return (lhs.mapIterator == rhs.mapIterator && lhs.m_vectorIndex == rhs.m_vectorIndex);
+ }
+ Q_DECLARE_EQUALITY_COMPARABLE(ResultIteratorBase)
protected:
QMap<int, ResultItem>::const_iterator mapIterator;
int m_vectorIndex;
@@ -134,6 +143,14 @@ protected:
}
public:
+ template <typename T, typename...Args>
+ int emplaceResult(int index, Args&&...args)
+ {
+ if (containsValidResultItem(index)) // reject if already present
+ return -1;
+ return addResult(index, static_cast<void *>(new T(std::forward<Args>(args)...)));
+ }
+
template <typename T>
int addResult(int index, const T *result)
{
@@ -149,10 +166,9 @@ public:
template <typename T>
int moveResult(int index, T &&result)
{
- if (containsValidResultItem(index)) // reject if already present
- return -1;
+ static_assert(!std::is_reference_v<T>, "trying to move from an lvalue!");
- return addResult(index, static_cast<void *>(new T(std::move_if_noexcept(result))));
+ return emplaceResult<std::remove_cv_t<T>>(index, std::forward<T>(result));
}
template<typename T>