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/qtconcurrentrun.cpp | |
| 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/qtconcurrentrun.cpp')
| -rw-r--r-- | src/concurrent/qtconcurrentrun.cpp | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/concurrent/qtconcurrentrun.cpp b/src/concurrent/qtconcurrentrun.cpp index 978bc8cd8dc..8347440b66e 100644 --- a/src/concurrent/qtconcurrentrun.cpp +++ b/src/concurrent/qtconcurrentrun.cpp @@ -89,6 +89,26 @@ the function. Changes made to the arguments after calling QtConcurrent::run() are \e not visible to the thread. + Note that QtConcurrent::run does not support calling overloaded functions + directly. For example, the code below won't compile: + +//! [run-with-overload-calls] + \snippet code/src_concurrent_qtconcurrentrun.cpp 15 + + The easiest workaround is to call the overloaded function through lambda: + + \snippet code/src_concurrent_qtconcurrentrun.cpp 16 + + Or you can tell the compiler which overload to choose by using a + \c static_cast: + + \snippet code/src_concurrent_qtconcurrentrun.cpp 17 + + Or qOverload: + + \snippet code/src_concurrent_qtconcurrentrun.cpp 18 +//! [run-with-overload-calls] + \section2 Returning Values from the Function Any return value from the function is available via QFuture: |
