3

我正在尝试将多个std::futures 保存在一个QMap. 这QMap是我班级的成员变量:

QMap<QString, std::future<cv::Mat>> threads;

我现在想std::async在这张地图中存储多次调用的结果,如下所示:

this->threads.insert(filename, std::async(std::launch::async, &MainInterface::readImage, this, path, true));

此处异步调用的函数readImage如下所示:

cv::Mat MainInterface::readImage(QString path, bool emitSignals) {
    //some code
    return image;
}

所以异步函数的返回值应该是std::future<cv::Mat>我认为的。但是,在尝试编译时,Visual Studio 2015 给了我以下编译器错误:

no instance of overloaded function "QMap<Key, T>::insert [with Key=QString, T=std::future<cv::Mat>]" matches the argument list, argument types are: (QString, std::future<cv::Mat (&)(QString path, bool emitSignals)>), object type is: QMap<QString, std::future<cv::Mat>>

令我困惑的是返回类型std::future<cv::Mat (&)(QString path, bool emitSignals)>,这与std::future<cv::Mat>我的预期不同。

4

0 回答 0