Skip to content
This repository has been archived by the owner on Dec 12, 2023. It is now read-only.

Unable to create a AsyncFuture::Deferred<QList<T>> #23

Open
remster opened this issue Nov 27, 2019 · 6 comments
Open

Unable to create a AsyncFuture::Deferred<QList<T>> #23

remster opened this issue Nov 27, 2019 · 6 comments

Comments

@remster
Copy link

remster commented Nov 27, 2019

This is a very handy library - thank you. But:
Consider this function:

QFuture<QList<double>> foo() {
    AsyncFuture::Deferred<QList<double>> _terrain_fetched;
    _terrain_fetched.complete(QList<double>());
    return _terrain_fetched.future();
}

and the compiler error:

In file included from ../foo.h:7,
                 from ../foo.cpp:4:
../AirBoss-MissionPlanner/src/SmartMissionPlanner/AsyncFuture.h: In instantiation of ‘void AsyncFuture::Private::DeferredFuture<T>::reportResult(QList<R>&) [with R = double; T = QList<double>]’:
../AirBoss-MissionPlanner/src/SmartMissionPlanner/AsyncFuture.h:505:9:   required from ‘void AsyncFuture::Private::DeferredFuture<T>::complete(QList<R>&) [with R = double; T = QList<double>]’
../AirBoss-MissionPlanner/src/SmartMissionPlanner/AsyncFuture.h:1280:9:   required from ‘void AsyncFuture::Deferred<T>::complete(T) [with T = QList<double>]’
../foo.cpp:78:46:   required from here
../AirBoss-MissionPlanner/src/SmartMissionPlanner/AsyncFuture.h:661:46: error: no matching function for call to ‘AsyncFuture::Private::DeferredFuture<QList<double> >::reportResult(double&, int&)’
             QFutureInterface<T>::reportResult(value[i], i);
             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~
In file included from ../../../Qt5.12.5/5.12.5/gcc_64/include/QtCore/qfuture.h:45,
                 from ../../../Qt5.12.5/5.12.5/gcc_64/include/QtCore/QtCore:85,
                 from ../../../Qt5.12.5/5.12.5/gcc_64/include/QtConcurrent/QtConcurrentDepends:3,
                 from ../../../Qt5.12.5/5.12.5/gcc_64/include/QtConcurrent/QtConcurrent:3,
                 from ../foo.cpp:1:
../../../Qt5.12.5/5.12.5/gcc_64/include/QtCore/qfutureinterface.h:189:13: note: candidate: ‘void QFutureInterface<T>::reportResult(const T*, int) [with T = QList<double>]’
 inline void QFutureInterface<T>::reportResult(const T *result, int index)
             ^~~~~~~~~~~~~~~~~~~
../../../Qt5.12.5/5.12.5/gcc_64/include/QtCore/qfutureinterface.h:189:13: note:   no known conversion for argument 1 from ‘double’ to ‘const QList<double>*’
../../../Qt5.12.5/5.12.5/gcc_64/include/QtCore/qfutureinterface.h:209:13: note: candidate: ‘void QFutureInterface<T>::reportResult(const T&, int) [with T = QList<double>]’
 inline void QFutureInterface<T>::reportResult(const T &result, int index)
             ^~~~~~~~~~~~~~~~~~~
../../../Qt5.12.5/5.12.5/gcc_64/include/QtCore/qfutureinterface.h:209:13: note:   no known conversion for argument 1 from ‘double’ to ‘const QList<double>&’
../foo.cpp:43:40: warning: ‘airmap::geography::bounding_box fromQt(const QGeoRectangle&)’ defined but not used [-Wunused-function]
 static airmap::geography::bounding_box fromQt(const QGeoRectangle& bbox) {

for some reason the compiler prefers to match this instead of this.

@redturtlepower
Copy link

This is due to template resolution. Use a QVector instead of a QList.

  • Using a QList or no container, your future will contain multiple results.
  • Using a QVector, your future will contain a single result, e.g. the QVector that contains all further results.

@nikkiwritescode
Copy link

This is due to template resolution. Use a QVector instead of a QList.

* Using a QList or no container, your future will contain multiple results.

* Using a QVector, your future will contain a single result, e.g. the QVector that contains all further results.

As of Qt6, QVector is now an alias for QList, so this error pops no matter which one you use.

@CJYate
Copy link

CJYate commented Oct 20, 2023

This is due to template resolution. Use a QVector instead of a QList.

* Using a QList or no container, your future will contain multiple results.

* Using a QVector, your future will contain a single result, e.g. the QVector that contains all further results.

As of Qt6, QVector is now an alias for QList, so this error pops no matter which one you use.

This is a breaking change for me (at least, it is as of today because I've tried to use it with a Future holding a QVector...!)

@vpicaver
Copy link
Contributor

Is this an issue on the current master? This repository is currently maintained on https://github.com/vpicaver/asyncfuture

@CJYate
Copy link

CJYate commented Oct 25, 2023 via email

vpicaver added a commit to vpicaver/asyncfuture that referenced this issue Oct 25, 2023
Asyncfuture now detects if QList or QVector is passed to the correct
QFutureInterface<T>::reportResult

This fixes issue 23 listed in benlau#23
@vpicaver
Copy link
Contributor

@remster Do you think you could close this issue. It has been fixed in vpicaver@900e4a2

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants