首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >QtConcurrent::映射未编译

QtConcurrent::映射未编译
EN

Stack Overflow用户
提问于 2020-01-14 23:22:47
回答 1查看 69关注 0票数 0

我正在尝试使用QtConcurrent::mapped,但我无法使其工作。这应该很简单:

代码语言:javascript
复制
class ChainInfo {
};


class Chain {
public:
   ChainInfo GetInfo() const;
};


void CalculateInfo(QList<Chain *> Chains) const {
   auto GetChainInfo = [](Chain const *pChain) {
      return pChain->GetInfo();
   };

   auto ChainInfos = QtConcurrent::mapped(Chains, GetChainInfo);
}

我得到以下编译错误:

代码语言:javascript
复制
QtConcurrent/qtconcurrentmapkernel.h(162): error C2039: 'result_type': is not a member of 'CalculateInfo::<lambda_7571384993bda001f6e6e0e4e3ad7d4a>'
Link.cpp(193): note: see declaration of 'CalculateInfo::<lambda_7571384993bda001f6e6e0e4e3ad7d4a>'
QtConcurrent/qtconcurrentmapkernel.h(213): note: see reference to class template instantiation 'QtConcurrent::MappedEachKernel<QList<Chain *>::const_iterator,Functor>' being compiled
        with
        [
            Functor=CalculateInfo::<lambda_7571384993bda001f6e6e0e4e3ad7d4a>
        ]
QtConcurrent/qtconcurrentmapkernel.h(237): note: see reference to class template instantiation 'QtConcurrent::SequenceHolder1<Sequence,QtConcurrent::MappedEachKernel<QList<Chain *>::const_iterator,Functor>,Functor>' being compiled
        with
        [
            Sequence=QList<Chain *>,
            Functor=CalculateInfo::<lambda_7571384993bda001f6e6e0e4e3ad7d4a>
        ]
qtconcurrent\qtconcurrentmap.h(132): note: see reference to function template instantiation 'QtConcurrent::ThreadEngineStarter<void> QtConcurrent::startMapped<void,Sequence,T>(const Sequence &,Functor)' being compiled
        with
        [
            Sequence=QList<Chain *>,
            T=CalculateInfo::<lambda_7571384993bda001f6e6e0e4e3ad7d4a>,
            Functor=CalculateInfo::<lambda_7571384993bda001f6e6e0e4e3ad7d4a>
        ]
Link.cpp(195): note: see reference to function template instantiation 'QFuture<void> QtConcurrent::mapped<QList<Chain *>,CalculateInfo::<lambda_7571384993bda001f6e6e0e4e3ad7d4a>>(const Sequence &,MapFunctor)' being compiled
        with
        [
            Sequence=QList<Chain *>,
            MapFunctor=CalculateInfo::<lambda_7571384993bda001f6e6e0e4e3ad7d4a>
        ]
QtConcurrent/qtconcurrentmapkernel.h(162): error C2146: syntax error: missing '>' before identifier 'result_type'
QtConcurrent/qtconcurrentmapkernel.h(165): error C2039: 'result_type': is not a member of 'CalculateInfo::<lambda_7571384993bda001f6e6e0e4e3ad7d4a>'
Link.cpp(193): note: see declaration of 'CalculateInfo::<lambda_7571384993bda001f6e6e0e4e3ad7d4a>'
QtConcurrent/qtconcurrentmapkernel.h(165): error C3646: 'T': unknown override specifier
QtConcurrent/qtconcurrentmapkernel.h(165): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
QtConcurrent/qtconcurrentmapkernel.h(167): error C3646: 'ReturnType': unknown override specifier
QtConcurrent/qtconcurrentmapkernel.h(167): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
QtConcurrent/qtconcurrentmapkernel.h(237): error C2440: 'return': cannot convert from 'QtConcurrent::ThreadEngineStarter<int>' to 'QtConcurrent::ThreadEngineStarter<void>'
QtConcurrent/qtconcurrentmapkernel.h(237): note: No constructor could take the source type, or constructor overload resolution was ambiguous
         dpclosedguielement.cpp
         dpclusterelement.cpp
         dpdimensioncontroller.cpp
         dpexternaldocumentsload.cpp
         dpflowsymbol.cpp
         dpguilink.cpp
         dpguisymbol.cpp

你知道可能出了什么问题吗?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2020-01-15 15:56:10

我可以通过指定lambda函数的类型来解决这个问题,而不是仅仅使用auto

代码语言:javascript
复制
std::function<ChainInfo(Chain const *)> GetChainInfo = [](Chain const *pChain) {
   return pChain->GetInfo();
};
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/59736814

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档