summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSona Kurazyan <sona.kurazyan@qt.io>2021-07-22 18:49:45 +0200
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2021-08-18 21:42:50 +0000
commitbcc7a9dd7af3a630e2fe79ded5ce0a3a7a745d5a (patch)
treead47e6f27411bf6980e9bf6095bcd2618ef2f15c
parent88373a370ad12c8f81ee3497c5d1d87e70f446ee (diff)
QtConcurrent: fix examples of overloaded methods in docs
Wrap the overloaded methods in qOverload(), to make the examples compile. Also remove the extra whitespaces when declaring nested templates. Change-Id: If438caa6d705d9036dae45278fb26e080918da89 Reviewed-by: Karsten Heimrich <karsten.heimrich@qt.io> Reviewed-by: MÃ¥rten Nordheim <marten.nordheim@qt.io> (cherry picked from commit 8aefbe67bf445d51f41c16ec00bc5ce3ec18ded5) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r--src/concurrent/doc/snippets/code/src_concurrent_qtconcurrentfilter.cpp10
-rw-r--r--src/concurrent/doc/snippets/code/src_concurrent_qtconcurrentmap.cpp6
-rw-r--r--src/concurrent/qtconcurrentfilter.cpp5
-rw-r--r--src/concurrent/qtconcurrentmap.cpp5
4 files changed, 18 insertions, 8 deletions
diff --git a/src/concurrent/doc/snippets/code/src_concurrent_qtconcurrentfilter.cpp b/src/concurrent/doc/snippets/code/src_concurrent_qtconcurrentfilter.cpp
index 0e0f414b13..e271b33b9e 100644
--- a/src/concurrent/doc/snippets/code/src_concurrent_qtconcurrentfilter.cpp
+++ b/src/concurrent/doc/snippets/code/src_concurrent_qtconcurrentfilter.cpp
@@ -82,7 +82,7 @@ void addToDictionary(QSet<QString> &dictionary, const QString &string)
}
QStringList strings = ...;
-QFuture<QSet<QString> > dictionary = QtConcurrent::filteredReduced(strings, allLowerCase, addToDictionary);
+QFuture<QSet<QString>> dictionary = QtConcurrent::filteredReduced(strings, allLowerCase, addToDictionary);
//! [4]
@@ -93,7 +93,7 @@ QFuture<QString> lowerCaseStrings = QtConcurrent::filtered(strings.constBegin(),
// filter in-place only works on non-const iterators
QFuture<void> future = QtConcurrent::filter(strings.begin(), strings.end(), allLowerCase);
-QFuture<QSet<QString> > dictionary = QtConcurrent::filteredReduced(strings.constBegin(), strings.constEnd(), allLowerCase, addToDictionary);
+QFuture<QSet<QString>> dictionary = QtConcurrent::filteredReduced(strings.constBegin(), strings.constEnd(), allLowerCase, addToDictionary);
//! [5]
@@ -121,7 +121,8 @@ QFuture<QImage> grayscaleImages = QtConcurrent::filtered(images, &QImage::isGray
// create a set of all printable characters
QList<QChar> characters = ...;
-QFuture<QSet<QChar> > set = QtConcurrent::filteredReduced(characters, &QChar::isPrint, &QSet<QChar>::insert);
+QFuture<QSet<QChar>> set = QtConcurrent::filteredReduced(characters, qOverload<>(&QChar::isPrint),
+ qOverload<const QChar&>(&QSet<QChar>::insert));
//! [7]
@@ -131,7 +132,8 @@ QFuture<QSet<QChar> > set = QtConcurrent::filteredReduced(characters, &QChar::is
// create a dictionary of all lower cased strings
extern bool allLowerCase(const QString &string);
QStringList strings = ...;
-QFuture<QSet<int> > averageWordLength = QtConcurrent::filteredReduced(strings, allLowerCase, QSet<QString>::insert);
+QFuture<QSet<QString>> lowerCase = QtConcurrent::filteredReduced(strings, allLowerCase,
+ qOverload<const QString&>(&QSet<QString>::insert));
// create a collage of all gray scale images
extern void addToCollage(QImage &collage, const QImage &grayscaleImage);
diff --git a/src/concurrent/doc/snippets/code/src_concurrent_qtconcurrentmap.cpp b/src/concurrent/doc/snippets/code/src_concurrent_qtconcurrentmap.cpp
index 659925a1c6..3913414b65 100644
--- a/src/concurrent/doc/snippets/code/src_concurrent_qtconcurrentmap.cpp
+++ b/src/concurrent/doc/snippets/code/src_concurrent_qtconcurrentmap.cpp
@@ -135,7 +135,8 @@ QFuture<QImage> bgrImages = QtConcurrent::mapped(images,
// Create a set of the lengths of all strings in a list.
QStringList strings = ...;
-QFuture<QSet<int> > wordLengths = QtConcurrent::mappedReduced(strings, &QString::length, &QSet<int>::insert);
+QFuture<QSet<int>> wordLengths = QtConcurrent::mappedReduced(strings, &QString::length,
+ qOverload<const int&>(&QSet<int>::insert));
//! [8]
@@ -150,7 +151,8 @@ QFuture<int> averageWordLength = QtConcurrent::mappedReduced(strings, &QString::
// Create a set of the color distribution of all images in a list.
extern int colorDistribution(const QImage &string);
QList<QImage> images = ...;
-QFuture<QSet<int> > totalColorDistribution = QtConcurrent::mappedReduced(images, colorDistribution, QSet<int>::insert);
+QFuture<QSet<int>> totalColorDistribution = QtConcurrent::mappedReduced(images, colorDistribution,
+ qOverload<const int&>(&QSet<int>::insert));
//! [9]
diff --git a/src/concurrent/qtconcurrentfilter.cpp b/src/concurrent/qtconcurrentfilter.cpp
index 2bec2a6eb9..b5f7e95a90 100644
--- a/src/concurrent/qtconcurrentfilter.cpp
+++ b/src/concurrent/qtconcurrentfilter.cpp
@@ -134,7 +134,10 @@
\snippet code/src_concurrent_qtconcurrentfilter.cpp 7
- Note that when using QtConcurrent::filteredReduced(), you can mix the use of
+ Note the use of qOverload. It is needed to resolve the ambiguity for the
+ methods, that have multiple overloads.
+
+ Also note that when using QtConcurrent::filteredReduced(), you can mix the use of
normal and member functions freely:
\snippet code/src_concurrent_qtconcurrentfilter.cpp 8
diff --git a/src/concurrent/qtconcurrentmap.cpp b/src/concurrent/qtconcurrentmap.cpp
index d68dd63bb8..e0a2eb4a88 100644
--- a/src/concurrent/qtconcurrentmap.cpp
+++ b/src/concurrent/qtconcurrentmap.cpp
@@ -260,7 +260,10 @@
\snippet code/src_concurrent_qtconcurrentmap.cpp 8
- Note that when using QtConcurrent::mappedReduced(), you can mix the use of
+ Note the use of qOverload. It is needed to resolve the ambiguity for the
+ methods, that have multiple overloads.
+
+ Also note that when using QtConcurrent::mappedReduced(), you can mix the use of
normal and member functions freely:
\snippet code/src_concurrent_qtconcurrentmap.cpp 9