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>
This commit is contained in:
parent
88373a370a
commit
bcc7a9dd7a
@ -121,7 +121,8 @@ QFuture<QImage> grayscaleImages = QtConcurrent::filtered(images, &QImage::isGray
|
|||||||
|
|
||||||
// create a set of all printable characters
|
// create a set of all printable characters
|
||||||
QList<QChar> 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]
|
//! [7]
|
||||||
|
|
||||||
|
|
||||||
@ -131,7 +132,8 @@ QFuture<QSet<QChar> > set = QtConcurrent::filteredReduced(characters, &QChar::is
|
|||||||
// create a dictionary of all lower cased strings
|
// create a dictionary of all lower cased strings
|
||||||
extern bool allLowerCase(const QString &string);
|
extern bool allLowerCase(const QString &string);
|
||||||
QStringList strings = ...;
|
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
|
// create a collage of all gray scale images
|
||||||
extern void addToCollage(QImage &collage, const QImage &grayscaleImage);
|
extern void addToCollage(QImage &collage, const QImage &grayscaleImage);
|
||||||
|
@ -135,7 +135,8 @@ QFuture<QImage> bgrImages = QtConcurrent::mapped(images,
|
|||||||
|
|
||||||
// Create a set of the lengths of all strings in a list.
|
// Create a set of the lengths of all strings in a list.
|
||||||
QStringList strings = ...;
|
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]
|
//! [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.
|
// Create a set of the color distribution of all images in a list.
|
||||||
extern int colorDistribution(const QImage &string);
|
extern int colorDistribution(const QImage &string);
|
||||||
QList<QImage> images = ...;
|
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]
|
//! [9]
|
||||||
|
|
||||||
|
|
||||||
|
@ -134,7 +134,10 @@
|
|||||||
|
|
||||||
\snippet code/src_concurrent_qtconcurrentfilter.cpp 7
|
\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:
|
normal and member functions freely:
|
||||||
|
|
||||||
\snippet code/src_concurrent_qtconcurrentfilter.cpp 8
|
\snippet code/src_concurrent_qtconcurrentfilter.cpp 8
|
||||||
|
@ -260,7 +260,10 @@
|
|||||||
|
|
||||||
\snippet code/src_concurrent_qtconcurrentmap.cpp 8
|
\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:
|
normal and member functions freely:
|
||||||
|
|
||||||
\snippet code/src_concurrent_qtconcurrentmap.cpp 9
|
\snippet code/src_concurrent_qtconcurrentmap.cpp 9
|
||||||
|
Loading…
x
Reference in New Issue
Block a user