From 8aefbe67bf445d51f41c16ec00bc5ce3ec18ded5 Mon Sep 17 00:00:00 2001 From: Sona Kurazyan Date: Thu, 22 Jul 2021 18:49:45 +0200 Subject: QtConcurrent: fix examples of overloaded methods in docs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Wrap the overloaded methods in qOverload(), to make the examples compile. Also remove the extra whitespaces when declaring nested templates. Pick-to: 6.1 6.2 Change-Id: If438caa6d705d9036dae45278fb26e080918da89 Reviewed-by: Karsten Heimrich Reviewed-by: MÃ¥rten Nordheim --- .../doc/snippets/code/src_concurrent_qtconcurrentfilter.cpp | 10 ++++++---- .../doc/snippets/code/src_concurrent_qtconcurrentmap.cpp | 6 ++++-- src/concurrent/qtconcurrentfilter.cpp | 5 ++++- src/concurrent/qtconcurrentmap.cpp | 5 ++++- 4 files changed, 18 insertions(+), 8 deletions(-) (limited to 'src/concurrent') diff --git a/src/concurrent/doc/snippets/code/src_concurrent_qtconcurrentfilter.cpp b/src/concurrent/doc/snippets/code/src_concurrent_qtconcurrentfilter.cpp index b9ff35c798..30bbf0af0a 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 &dictionary, const QString &string) } QStringList strings = ...; -QFuture > dictionary = QtConcurrent::filteredReduced(strings, allLowerCase, addToDictionary); +QFuture> dictionary = QtConcurrent::filteredReduced(strings, allLowerCase, addToDictionary); //! [4] @@ -93,7 +93,7 @@ QFuture lowerCaseStrings = QtConcurrent::filtered(strings.constBegin(), // filter in-place only works on non-const iterators QFuture future = QtConcurrent::filter(strings.begin(), strings.end(), allLowerCase); -QFuture > dictionary = QtConcurrent::filteredReduced(strings.constBegin(), strings.constEnd(), allLowerCase, addToDictionary); +QFuture> dictionary = QtConcurrent::filteredReduced(strings.constBegin(), strings.constEnd(), allLowerCase, addToDictionary); //! [5] @@ -121,7 +121,8 @@ QFuture grayscaleImages = QtConcurrent::filtered(images, &QImage::isGray // create a set of all printable characters QList characters = ...; -QFuture > set = QtConcurrent::filteredReduced(characters, &QChar::isPrint, &QSet::insert); +QFuture> set = QtConcurrent::filteredReduced(characters, qOverload<>(&QChar::isPrint), + qOverload(&QSet::insert)); //! [7] @@ -131,7 +132,8 @@ QFuture > set = QtConcurrent::filteredReduced(characters, &QChar::is // create a dictionary of all lower cased strings extern bool allLowerCase(const QString &string); QStringList strings = ...; -QFuture > averageWordLength = QtConcurrent::filteredReduced(strings, allLowerCase, QSet::insert); +QFuture> lowerCase = QtConcurrent::filteredReduced(strings, allLowerCase, + qOverload(&QSet::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 9c91715ac0..c57f3bf6db 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 bgrImages = QtConcurrent::mapped(images, // Create a set of the lengths of all strings in a list. QStringList strings = ...; -QFuture > wordLengths = QtConcurrent::mappedReduced(strings, &QString::length, &QSet::insert); +QFuture> wordLengths = QtConcurrent::mappedReduced(strings, &QString::length, + qOverload(&QSet::insert)); //! [8] @@ -150,7 +151,8 @@ QFuture 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 images = ...; -QFuture > totalColorDistribution = QtConcurrent::mappedReduced(images, colorDistribution, QSet::insert); +QFuture> totalColorDistribution = QtConcurrent::mappedReduced(images, colorDistribution, + qOverload(&QSet::insert)); //! [9] diff --git a/src/concurrent/qtconcurrentfilter.cpp b/src/concurrent/qtconcurrentfilter.cpp index 663507be35..ae913a839e 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 8abfec4baf..26f84cf054 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 -- cgit v1.2.3