diff options
author | Sona Kurazyan <sona.kurazyan@qt.io> | 2020-12-22 13:06:25 +0100 |
---|---|---|
committer | Sona Kurazyan <sona.kurazyan@qt.io> | 2020-12-23 18:34:21 +0100 |
commit | f1f4fd16fdd219701261d305e6d9f7abcb8bf4a9 (patch) | |
tree | 0746740bb93561c6c9c044d4f2d8ef9f1a76b6e0 /src/concurrent/doc | |
parent | f3747c21d381cb69819c461207b3918f36d10066 (diff) |
Document that QtConcurrent::run doesn't support overloaded functions
After improving QtConcurrent::run() to use parameter packs for the
arguments (see c977e74afd18afff8729070f631e6b7a3f2887f5), calling
overloaded functions is ambiguous. Updated the porting guide and the
documentation to mention this and describe possible workarounds.
Task-number: QTBUG-89648
Pick-to: 6.0
Change-Id: I4c1f996ae67bce8c13cc1f99f54240295db6ae1d
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
Diffstat (limited to 'src/concurrent/doc')
-rw-r--r-- | src/concurrent/doc/snippets/code/src_concurrent_qtconcurrentrun.cpp | 18 | ||||
-rw-r--r-- | src/concurrent/doc/src/qt6-changes.qdoc | 5 |
2 files changed, 23 insertions, 0 deletions
diff --git a/src/concurrent/doc/snippets/code/src_concurrent_qtconcurrentrun.cpp b/src/concurrent/doc/snippets/code/src_concurrent_qtconcurrentrun.cpp index bf39119c51..59b65dcb3a 100644 --- a/src/concurrent/doc/snippets/code/src_concurrent_qtconcurrentrun.cpp +++ b/src/concurrent/doc/snippets/code/src_concurrent_qtconcurrentrun.cpp @@ -230,3 +230,21 @@ run<double>(f); // this will select the 2nd overload // run(f); // error, both candidate overloads potentially match //! [14] +//! [15] +void foo(int arg); +void foo(int arg1, int arg2); +... +QFuture<void> future = QtConcurrent::run(foo, 42); +//! [15] + +//! [16] +QFuture<void> future = QtConcurrent::run([] { foo(42); }); +//! [16] + +//! [17] +QFuture<void> future = QtConcurrent::run(static_cast<void(*)(int)>(foo), 42); +//! [17] + +//! [18] +QFuture<void> future = QtConcurrent::run(qOverload<int>(foo), 42); +//! [18] diff --git a/src/concurrent/doc/src/qt6-changes.qdoc b/src/concurrent/doc/src/qt6-changes.qdoc index 9614790bac..8711209e13 100644 --- a/src/concurrent/doc/src/qt6-changes.qdoc +++ b/src/concurrent/doc/src/qt6-changes.qdoc @@ -71,6 +71,11 @@ QFuture<void> future = QtConcurrent::run(&QImage::invertPixels, &image, QImage::InvertRgba); \endcode + Another side effect is that \c QtConcurrent::run() will not work with + overloaded functions anymore. For example, the code below won't compile: + + \include qtconcurrentrun.cpp run-with-overload-calls + Other methods of QtConcurrent have no behavioral changes and do not introduce source compatibility breaks. */ |