繁体   English   中英

使用Lambda时C ++没有匹配的函数调用进行转换

[英]C++ no matching function call to transform when using lambda

好吧,这很困扰。 适用于Visual Studio,但不适用于Code :: Blocks(GNU编译器)。

transform(m_teams.begin(), m_teams.end(), inserter(teamNames, teamNames.end()),
    [](stVecPair team) -> string { return team.first; });

m_teams是一个映射: typedef map<string, vector<Person*> > stVecMap;

teamNames是一个集合: typedef set<string> StrSet;

stVecPair是与m_teams匹配的一对: typedef pair<string, vector<Person*> > stVecPair;

完全错误

error: no matching function for call to 'transform(std::map<std::basic_string<char>, 
std::vector<Person*> >::const_iterator, std::map<std::basic_string<char>, 
std::vector<Person*> >::const_iterator, std::insert_iterator<std::set<std::basic_string<char> > >, 
RaceAnalyzer::teams() const::<lambda(RaceAnalyzer::stVecPair&)>)

如我所评论,您忘记了-std=c++11选项> o <

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM