diff --git a/src/corelib/thread/qfuture_impl.h b/src/corelib/thread/qfuture_impl.h index 780e39dd8cb..01afa64cd6e 100644 --- a/src/corelib/thread/qfuture_impl.h +++ b/src/corelib/thread/qfuture_impl.h @@ -1106,7 +1106,9 @@ void addCompletionHandlers(const std::shared_ptr &context, const st addCompletionHandlersImpl(context, t); } -template +template, isQFuture>, + bool> = true> QFuture whenAllImpl(InputIt first, InputIt last) { const qsizetype size = std::distance(first, last); @@ -1142,7 +1144,9 @@ QFuture whenAllImpl(Futures &&... futures) return context->promise.future(); } -template +template, isQFuture>, + bool> = true> QFuture::type>> whenAnyImpl(InputIt first, InputIt last) { diff --git a/tests/auto/corelib/thread/qfuture/tst_qfuture.cpp b/tests/auto/corelib/thread/qfuture/tst_qfuture.cpp index 7a8cd707d7c..b3c5f757416 100644 --- a/tests/auto/corelib/thread/qfuture/tst_qfuture.cpp +++ b/tests/auto/corelib/thread/qfuture/tst_qfuture.cpp @@ -233,6 +233,7 @@ private slots: void getFutureInterface(); void convertQMetaType(); + void whenAllwhenAnyOverloadResolution(); void whenAllIterators(); void whenAllIteratorsWithCanceled(); void whenAllIteratorsWithFailed(); @@ -4447,6 +4448,14 @@ void tst_QFuture::convertQMetaType() QVERIFY(voidFuture.isFinished()); } +void tst_QFuture::whenAllwhenAnyOverloadResolution() +{ + // Compile-only test. These could fail to compile due to picking a wrong + // overload of *Impl() methods. See QTBUG-131959 + [[maybe_unused]] auto f = QtFuture::whenAll(QFuture{}, QFuture{}); + [[maybe_unused]] auto ff = QtFuture::whenAny(QFuture{}, QFuture{}); +} + template void testWhenAllIterators() {